An HTTP wrapper around the wonderful requests library to make it easier for new users and old.
Project description
HTTP Class
The HTTP
class provides a simplified interface for making HTTP requests using the popular requests
library. It supports various functionalities like setting a custom user agent, using proxies, and handling proxy authentication.
Features
- Simple methods for common HTTP requests (
GET
,POST
, etc.) - Customizable user agent
- Proxy support
- Proxy authentication
- Persistent sessions
Installation
Before using the HTTP
class, ensure you have the requests
library installed:
pip install CD-HTTP=```
## Usage
### Initialization
To start using the `HTTP` class, first create an instance:
```python
from http_class import HTTP
http_client = HTTP()
Making a GET Request
response = http_client.get("https://www.example.com")
Making a POST Request
data = {"key": "value"}
response = http_client.post("https://api.example.com", json=data)
Using a Custom User Agent
response = http_client.get("https://www.example.com", user_agent="MyCustomUserAgent/1.0")
Using a Proxy
response = http_client.get("https://www.example.com", proxy="http://my-proxy.com:8080")
Using Proxy Authentication
response = http_client.get("https://www.example.com", proxy="http://my-proxy.com:8080", proxy_username="username", proxy_password="password")
Passing Additional Headers
headers = {
"Authorization": "Bearer YOUR_TOKEN_HERE",
"Custom-Header": "CustomValue"
}
response = http_client.get("https://www.example.com", headers=headers)
Persistent Sessions
To start a persistent session:
http_client.start_session()
Your code goes between start_session() and close_session() To close the session:
http_client.close_session()
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
More documentation at: Code Docta
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.