Python Request Module (Requests Module)
- Previous Page Random Module
- Next Page Remove Duplicate Items from List
Example
Send a request to the web page and print the response text:
import requests x = requests.get('https://codew3c.com/python/demopage.htm') print(x.text)
Definition and Usage
requests
The module allows you to send HTTP requests using Python.
The HTTP request returns a response object that contains all the response data (content, encoding, status, etc.).
Download and install the request module
Navigate to the location of PIP via the command line, then type the following:
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip install requests
Syntax
requests.methodname(params)
Method
Method | Description |
---|---|
delete(url, args) | Send a DELETE request to the specified URL. |
get(url, params, args) | Send a GET request to the specified URL. |
head(url, args) | Send a HEAD request to the specified URL. |
patch(url, data, args) | Send a PATCH request to the specified URL. |
post(url, data, json, args) | Send a POST request to the specified URL. |
put(url, data, args) | Send a PUT request to the specified URL. |
request(method, url, args) | Send a request for the specified method to the specified URL. |
- Previous Page Random Module
- Next Page Remove Duplicate Items from List