Python Request is a Python library use to get request from the web pages. it is a Human Friendly HTTP Library. over 400,000 Download Everyday. Request Library is a License Under Apache 2.0. Read on to know the top 20 request libraries to use in 2022 for Data Science.
Syntax
requests.methodname(params)
Request Method
Method | Description |
GET | The GET method is use to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and no other effect data. |
POST | A POST is use to send data to the server using HTML From |
HEAD | It is similar to GET Method but it transfers the status line and the header section only. |
PUT | Replaces all the currently the target resource with the uploaded content. |
DELETE | Removes all the current the target resource given by URI. |
CONNECT | Establishes a passage to the server identifies by a given URI. |
OPTIONS | Describe the communication options for the target. |
TRACE |
Delete Request
This method sends a DELETE request to url.
Syntax
requests.delete(url, args)
Example
import requests
x = requests.delete(‘https://translate.google.co.in/’)
print(x.text)
Output: One record deleted.
GET request
The GET method is use to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and no other effect data is knows as GET Request.
Syntax
requests.get(url, params={key: value}, args)
Example of GET request
import requests
y = requests.get(‘https://translate.google.co.in/’)
print(y.status_code)
Head Request
It is similar to GET Method but it transfers the status line and the header section only.
syntax
requests.head(url, args)
EXample
import requests
y = requests.head(‘https://translate.google.co.in/’)
print(y.headers)
Output
{‘Content-Encoding’: ‘gzip’, ‘Cache-Control’: ‘public’, ‘Content-Type’: ‘text/html’, ‘Date’: ‘Sat Dec 03 2022 15:09:33 GMT+0530 (India Standard Time)’, ‘Server’: ‘Microsoft-IIS/7.5’, ‘Vary’: ‘Accept-Encoding’, ‘X-Frame-Options’: ‘SAMEORIGIN’, ‘X-Powered-By’: ‘PHP/5-4-2. ASP.NET’, ‘Content-Length’: ‘0’}
If you have any queries regarding this article or if I have missed something on this topic, please feel free to add in the comment down below for the audience. See you guys in another article.
To know more about Requests Library Functions in Python please Wikipedia Click Here
Stay Connected Stay Safe. Thank you
0 Comments