httpx-socks


Namehttpx-socks JSON
Version 0.9.1 PyPI version JSON
download
home_pagehttps://github.com/romis2012/httpx-socks
SummaryProxy (HTTP, SOCKS) transports for httpx
upload_time2024-03-06 05:49:46
maintainer
docs_urlNone
authorRoman Snegirev
requires_python
licenseApache 2
keywords httpx asyncio socks socks5 socks4 http proxy
VCS
bugtrack_url
requirements httpx httpcore anyio python-socks async-timeout trio sniffio
Travis-CI No Travis.
coveralls test coverage
            # httpx-socks

[![CI](https://github.com/romis2012/httpx-socks/actions/workflows/ci.yml/badge.svg)](https://github.com/romis2012/httpx-socks/actions/workflows/ci.yml)
[![Coverage Status](https://codecov.io/gh/romis2012/httpx-socks/branch/master/graph/badge.svg)](https://codecov.io/gh/romis2012/httpx-socks)
[![PyPI version](https://badge.fury.io/py/httpx-socks.svg)](https://pypi.python.org/pypi/httpx-socks)
<!--
[![Downloads](https://pepy.tech/badge/httpx-socks/month)](https://pepy.tech/project/httpx-socks)
-->

The `httpx-socks` package provides proxy transports for [httpx](https://github.com/encode/httpx) client. 
SOCKS4(a), SOCKS5(h), HTTP (tunneling) proxy supported.
It uses [python-socks](https://github.com/romis2012/python-socks) for core proxy functionality.


## Requirements
- Python >= 3.6
- httpx>=0.21.0
- python-socks>=2.0.0
- async-timeout>=3.0.1 (optional)
- trio>=0.16.0 (optional)


## Installation

only sync proxy support:
```
pip install httpx-socks
```

to include optional asyncio support (it requires async-timeout):
```
pip install httpx-socks[asyncio]
```

to include optional trio support:
```
pip install httpx-socks[trio]
```


## Usage

#### sync transport
```python
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 (asyncio, trio)
```python
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
```

#### secure proxy connections (aka "HTTPS proxies", experimental feature, both sync and async support)
```python
import ssl
import httpx
from httpx_socks import AsyncProxyTransport

async def fetch(url):
    proxy_ssl = ssl.SSLContext(ssl.PROTOCOL_TLS)
    proxy_ssl.verify_mode = ssl.CERT_REQUIRED
    proxy_ssl.load_verify_locations(...)
    
    transport = AsyncProxyTransport.from_url('http://user:password@127.0.0.1:8080', proxy_ssl=proxy_ssl)
    async with httpx.AsyncClient(transport=transport) as client:
        res = await client.get(url)
        return res.text
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/romis2012/httpx-socks",
    "name": "httpx-socks",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "httpx asyncio socks socks5 socks4 http proxy",
    "author": "Roman Snegirev",
    "author_email": "snegiryev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/13/34/23ed81d0511acee5b3ec1ba899162714a17bd3854ad4461528cb45518d35/httpx-socks-0.9.1.tar.gz",
    "platform": null,
    "description": "# httpx-socks\n\n[![CI](https://github.com/romis2012/httpx-socks/actions/workflows/ci.yml/badge.svg)](https://github.com/romis2012/httpx-socks/actions/workflows/ci.yml)\n[![Coverage Status](https://codecov.io/gh/romis2012/httpx-socks/branch/master/graph/badge.svg)](https://codecov.io/gh/romis2012/httpx-socks)\n[![PyPI version](https://badge.fury.io/py/httpx-socks.svg)](https://pypi.python.org/pypi/httpx-socks)\n<!--\n[![Downloads](https://pepy.tech/badge/httpx-socks/month)](https://pepy.tech/project/httpx-socks)\n-->\n\nThe `httpx-socks` package provides proxy transports for [httpx](https://github.com/encode/httpx) client. \nSOCKS4(a), SOCKS5(h), HTTP (tunneling) proxy supported.\nIt uses [python-socks](https://github.com/romis2012/python-socks) for core proxy functionality.\n\n\n## Requirements\n- Python >= 3.6\n- httpx>=0.21.0\n- python-socks>=2.0.0\n- async-timeout>=3.0.1 (optional)\n- trio>=0.16.0 (optional)\n\n\n## Installation\n\nonly sync proxy support:\n```\npip install httpx-socks\n```\n\nto include optional asyncio support (it requires async-timeout):\n```\npip install httpx-socks[asyncio]\n```\n\nto include optional trio support:\n```\npip install httpx-socks[trio]\n```\n\n\n## Usage\n\n#### sync transport\n```python\nimport httpx\nfrom httpx_socks import SyncProxyTransport\n\ndef fetch(url):\n    transport = SyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')\n    with httpx.Client(transport=transport) as client:\n        res = client.get(url)\n        return res.text\n```\n\n#### async transport (asyncio, trio)\n```python\nimport httpx\nfrom httpx_socks import AsyncProxyTransport\n\nasync def fetch(url):\n    transport = AsyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')\n    async with httpx.AsyncClient(transport=transport) as client:\n        res = await client.get(url)\n        return res.text\n```\n\n#### secure proxy connections (aka \"HTTPS proxies\", experimental feature, both sync and async support)\n```python\nimport ssl\nimport httpx\nfrom httpx_socks import AsyncProxyTransport\n\nasync def fetch(url):\n    proxy_ssl = ssl.SSLContext(ssl.PROTOCOL_TLS)\n    proxy_ssl.verify_mode = ssl.CERT_REQUIRED\n    proxy_ssl.load_verify_locations(...)\n    \n    transport = AsyncProxyTransport.from_url('http://user:password@127.0.0.1:8080', proxy_ssl=proxy_ssl)\n    async with httpx.AsyncClient(transport=transport) as client:\n        res = await client.get(url)\n        return res.text\n```\n",
    "bugtrack_url": null,
    "license": "Apache 2",
    "summary": "Proxy (HTTP, SOCKS) transports for httpx",
    "version": "0.9.1",
    "project_urls": {
        "Homepage": "https://github.com/romis2012/httpx-socks"
    },
    "split_keywords": [
        "httpx",
        "asyncio",
        "socks",
        "socks5",
        "socks4",
        "http",
        "proxy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f05e92a52ffdacf1a3a254e062c4c41fb371680cc774e82b33ea853b3c5eb327",
                "md5": "e3b2c7941843caad077b6cb45b971d35",
                "sha256": "d01dabfdf4da2a8d6c82986ddcfdbb5799a32a21eda0a0639934caf9411bf4a5"
            },
            "downloads": -1,
            "filename": "httpx_socks-0.9.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e3b2c7941843caad077b6cb45b971d35",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12745,
            "upload_time": "2024-03-06T05:49:45",
            "upload_time_iso_8601": "2024-03-06T05:49:45.380182Z",
            "url": "https://files.pythonhosted.org/packages/f0/5e/92a52ffdacf1a3a254e062c4c41fb371680cc774e82b33ea853b3c5eb327/httpx_socks-0.9.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "133423ed81d0511acee5b3ec1ba899162714a17bd3854ad4461528cb45518d35",
                "md5": "2245bd36d72f98e49ca2fe51f79809fe",
                "sha256": "80ab86bad96fdcbb44b59940f2d3218577a7f09a6d4fdeb2ebaf9ccdff4748a9"
            },
            "downloads": -1,
            "filename": "httpx-socks-0.9.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2245bd36d72f98e49ca2fe51f79809fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12425,
            "upload_time": "2024-03-06T05:49:46",
            "upload_time_iso_8601": "2024-03-06T05:49:46.969007Z",
            "url": "https://files.pythonhosted.org/packages/13/34/23ed81d0511acee5b3ec1ba899162714a17bd3854ad4461528cb45518d35/httpx-socks-0.9.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-06 05:49:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "romis2012",
    "github_project": "httpx-socks",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "httpx",
            "specs": [
                [
                    ">=",
                    "0.21.0"
                ],
                [
                    "<",
                    "0.28.0"
                ]
            ]
        },
        {
            "name": "httpcore",
            "specs": [
                [
                    "<",
                    "2.0"
                ],
                [
                    ">=",
                    "0.17.3"
                ]
            ]
        },
        {
            "name": "anyio",
            "specs": [
                [
                    "==",
                    "3.*"
                ]
            ]
        },
        {
            "name": "python-socks",
            "specs": [
                [
                    ">=",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "async-timeout",
            "specs": [
                [
                    ">=",
                    "3.0.1"
                ]
            ]
        },
        {
            "name": "trio",
            "specs": [
                [
                    ">=",
                    "0.16.0"
                ]
            ]
        },
        {
            "name": "sniffio",
            "specs": [
                [
                    ">=",
                    "1.1.0"
                ]
            ]
        }
    ],
    "lcname": "httpx-socks"
}
        
Elapsed time: 0.19910s