Skip to main content

Proxy (HTTP, SOCKS) transports for httpx

Project description

httpx-socks

Build Status Coverage Status PyPI version

The httpx-socks package provides proxy transports for httpx client. SOCKS4(a), SOCKS5, HTTP (tunneling) proxy supported. It uses python-socks for core proxy functionality.

Requirements

  • Python >= 3.6
  • httpx >= 0.13.3
  • python-socks[asyncio,trio] >= 1.0.1

Installation

pip install httpx-socks

Usage

sync transport

import httpx
from httpx_socks import SyncProxyTransport

def fetch(url):
    transport = SyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')
    with httpx.Client(transport=transport) as client:
        res = client.get(url)
        return res.text

async transport (both asyncio and trio supported)

import httpx
from httpx_socks import AsyncProxyTransport

async def fetch(url):
    transport = AsyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')
    async with httpx.AsyncClient(transport=transport) as client:
        res = await client.get(url)
        return res.text

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httpx-socks-0.2.10.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

httpx_socks-0.2.10-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page