Python-Anfrage-Modul (Requests Module)
- Previous Page Random Module
- Next Page Remove Duplicate Items from List
Beispiel
Senden Sie eine Anfrage an die Webseite und drucken Sie den Antworttext aus:
import requests x = requests.get('https://codew3c.com/python/demopage.htm') print(x.text)
Definition und Verwendung
requests
Das Modul ermöglicht es Ihnen, HTTP-Anfragen mit Python zu senden.
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 a specified method to the specified URL. |
- Previous Page Random Module
- Next Page Remove Duplicate Items from List