/cd_http

HTTP Client wrapper for requests library for beginners to Python.

Primary LanguagePythonMIT LicenseMIT

Based on the analysis of the cd_http package, here's a proposed structure for the README.md file for your PyPI/GitHub repository. This file showcases the features and provides examples of how to use the package.


cd_http

cd_http is a simple, yet powerful Python package for handling HTTP requests. Built on top of the popular requests library, it offers a streamlined interface for sending GET, POST, PUT, and DELETE requests, handling proxies, and downloading files. This package is perfect for applications that require basic HTTP interactions with custom configurations.

Features

  • Simplified HTTP Requests: Easily send GET, POST, PUT, and DELETE requests.
  • Proxy Support: Configure HTTP requests to go through proxies with or without authentication.
  • User-Agent Customization: Set custom user-agent strings for your requests.
  • Session Management: Supports persistent sessions for multiple requests.
  • File Download Utility: Facilitate the downloading of files from URLs.
  • Error Handling: Gracefully handle request errors and exceptions.

Installation

To install cd_http, run:

pip install cd_http

Usage

Basic Usage

Here's how to send a simple GET request:

from cd_http import HTTP

http_client = HTTP()
response = http_client.get("https://example.com")
print(response.text)

POST Request

Sending a POST request with data:

response = http_client.post("https://example.com/post", data={'key': 'value'})

Using Proxies

To send a request through a proxy:

response = http_client.get("https://example.com", proxy="http://proxyserver:port")

For a proxy requiring authentication:

response = http_client.get("https://example.com", proxy="http://proxyserver:port", proxy_username="user", proxy_password="password")

Downloading Files

Download a file from a URL:

http_client.download_file("path/to/save/file.jpg", "https://example.com/image.jpg")

Persistent Sessions

Start a persistent session for multiple requests:

http_client.start_session()
# Make multiple requests
http_client.close_session()

Requirements

  • Python 3.x
  • requests

Version

Current version: 0.1.2


Feel free to customize this README.md according to your project's specific needs. This template is designed to provide a clear and user-friendly introduction to your package, its features, and how to use it.