Requests is an elegant and simple HTTP library for Python, built for human beings. It allows you to send HTTP/1.1 requests easily, with features like automatic content decoding, session management, and JSON support.
Installation:
pip install requests
Key Features:
- Simple and intuitive API for GET, POST, PUT, DELETE requests
- Automatic JSON parsing and encoding
- Custom headers, query parameters, and form data support
- Connection pooling, SSL verification, and timeout settings
Code Example:
import requests
# Send GET request to a public API
response = requests.get('https://api.github.com')
print("Status Code:", response.status_code)
print("Content-Type:", response.headers['content-type'])
data = response.json()
print("Keys in response:", list(data.keys())[:5])
No comments:
Post a Comment