Python İstek Modülü
Örnek
Bir web sayfasına istekte bulunun ve yanıt metnini yazdırın:
import requests
x = requests.get('https://w3schools.com/python/demopage.htm')
print(x.text)
Tanım ve Kullanım
Modül requests
, Python kullanarak HTTP istekleri göndermenize izin verir.
HTTP isteği , tüm yanıt verileriyle (içerik, kodlama, durum vb.) bir Yanıt Nesnesi döndürür.
İstekler Modülünü İndirin ve Kurun
Komut satırınızda PIP konumuna gidin ve aşağıdakini yazın:
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip install requests
Sözdizimi
requests.methodname(params)
yöntemler
Method | Description |
---|---|
delete(url, args) | Sends a DELETE request to the specified url |
get(url, params, args) | Sends a GET request to the specified url |
head(url, args) | Sends a HEAD request to the specified url |
patch(url, data, args) | Sends a PATCH request to the specified url |
post(url, data, json, args) | Sends a POST request to the specified url |
put(url, data, args) | Sends a PUT request to the specified url |
request(method, url, args) | Sends a request of the specified method to the specified url |