aiohttp-socksx


Nameaiohttp-socksx JSON
Version 0.8.4 PyPI version JSON
download
home_pagehttps://github.com/romis2012/aiohttp-socks
SummaryProxy connector for aiohttp
upload_time2023-11-14 19:54:37
maintainer
docs_urlNone
authorRoman Snegirev
requires_python
licenseApache 2
keywords asyncio aiohttp socks socks5 socks4 http proxy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ## aiohttp-socks

[![CI](https://github.com/romis2012/aiohttp-socks/actions/workflows/ci.yml/badge.svg)](https://github.com/romis2012/aiohttp-socks/actions/workflows/ci.yml)
[![Coverage Status](https://codecov.io/gh/romis2012/aiohttp-socks/branch/master/graph/badge.svg)](https://codecov.io/gh/romis2012/aiohttp-socks)
[![PyPI version](https://badge.fury.io/py/aiohttp-socks.svg)](https://pypi.python.org/pypi/aiohttp-socks)
<!--
[![Downloads](https://pepy.tech/badge/aiohttp-socks/month)](https://pepy.tech/project/aiohttp-socks)
-->
The `aiohttp-socks` package provides a proxy connector for [aiohttp](https://github.com/aio-libs/aiohttp). 
Supports SOCKS4(a), SOCKS5(h), HTTP (tunneling) as well as Proxy chains.
It uses [python-socks](https://github.com/romis2012/python-socks) for core proxy functionality.


## Requirements
- Python >= 3.6
- aiohttp >= 2.3.2
- python-socks[asyncio] >= 1.0.1

## Installation
```
pip install aiohttp_socks
```

## Usage

#### aiohttp usage:
```python
import aiohttp
from aiohttp_socks import ProxyType, ProxyConnector, ChainProxyConnector


async def fetch(url):
    connector = ProxyConnector.from_url('socks5://user:password@127.0.0.1:1080')
    
    ### or use ProxyConnector constructor
    # connector = ProxyConnector(
    #     proxy_type=ProxyType.SOCKS5,
    #     host='127.0.0.1',
    #     port=1080,
    #     username='user',
    #     password='password',
    #     rdns=True
    # )
    
    ### proxy chaining (since ver 0.3.3)
    # connector = ChainProxyConnector.from_urls([
    #     'socks5://user:password@127.0.0.1:1080',
    #     'socks4://127.0.0.1:1081',
    #     'http://user:password@127.0.0.1:3128',
    # ])
    async with aiohttp.ClientSession(connector=connector) as session:
        async with session.get(url) as response:
            return await response.text()
```

#### aiohttp-socks also provides `open_connection` and `create_connection` functions:

```python
from aiohttp_socks import open_connection

async def fetch():
    reader, writer = await open_connection(
        proxy_url='socks5://user:password@127.0.0.1:1080',
        host='check-host.net',
        port=80
    )
    request = (b"GET /ip HTTP/1.1\r\n"
               b"Host: check-host.net\r\n"
               b"Connection: close\r\n\r\n")

    writer.write(request)
    return await reader.read(-1)
```

## Why yet another SOCKS connector for aiohttp

Unlike [aiosocksy](https://github.com/romis2012/aiosocksy), aiohttp_socks has only single point of integration with aiohttp. 
This makes it easier to maintain compatibility with new aiohttp versions.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/romis2012/aiohttp-socks",
    "name": "aiohttp-socksx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "asyncio aiohttp socks socks5 socks4 http proxy",
    "author": "Roman Snegirev",
    "author_email": "snegiryev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/09/4d/9f612a7967861091913fa40caf405fbbce757d700a89e6dcb75947a4176e/aiohttp_socksx-0.8.4.tar.gz",
    "platform": null,
    "description": "## aiohttp-socks\n\n[![CI](https://github.com/romis2012/aiohttp-socks/actions/workflows/ci.yml/badge.svg)](https://github.com/romis2012/aiohttp-socks/actions/workflows/ci.yml)\n[![Coverage Status](https://codecov.io/gh/romis2012/aiohttp-socks/branch/master/graph/badge.svg)](https://codecov.io/gh/romis2012/aiohttp-socks)\n[![PyPI version](https://badge.fury.io/py/aiohttp-socks.svg)](https://pypi.python.org/pypi/aiohttp-socks)\n<!--\n[![Downloads](https://pepy.tech/badge/aiohttp-socks/month)](https://pepy.tech/project/aiohttp-socks)\n-->\nThe `aiohttp-socks` package provides a proxy connector for [aiohttp](https://github.com/aio-libs/aiohttp). \nSupports SOCKS4(a), SOCKS5(h), HTTP (tunneling) as well as Proxy chains.\nIt uses [python-socks](https://github.com/romis2012/python-socks) for core proxy functionality.\n\n\n## Requirements\n- Python >= 3.6\n- aiohttp >= 2.3.2\n- python-socks[asyncio] >= 1.0.1\n\n## Installation\n```\npip install aiohttp_socks\n```\n\n## Usage\n\n#### aiohttp usage:\n```python\nimport aiohttp\nfrom aiohttp_socks import ProxyType, ProxyConnector, ChainProxyConnector\n\n\nasync def fetch(url):\n    connector = ProxyConnector.from_url('socks5://user:password@127.0.0.1:1080')\n    \n    ### or use ProxyConnector constructor\n    # connector = ProxyConnector(\n    #     proxy_type=ProxyType.SOCKS5,\n    #     host='127.0.0.1',\n    #     port=1080,\n    #     username='user',\n    #     password='password',\n    #     rdns=True\n    # )\n    \n    ### proxy chaining (since ver 0.3.3)\n    # connector = ChainProxyConnector.from_urls([\n    #     'socks5://user:password@127.0.0.1:1080',\n    #     'socks4://127.0.0.1:1081',\n    #     'http://user:password@127.0.0.1:3128',\n    # ])\n    async with aiohttp.ClientSession(connector=connector) as session:\n        async with session.get(url) as response:\n            return await response.text()\n```\n\n#### aiohttp-socks also provides `open_connection` and `create_connection` functions:\n\n```python\nfrom aiohttp_socks import open_connection\n\nasync def fetch():\n    reader, writer = await open_connection(\n        proxy_url='socks5://user:password@127.0.0.1:1080',\n        host='check-host.net',\n        port=80\n    )\n    request = (b\"GET /ip HTTP/1.1\\r\\n\"\n               b\"Host: check-host.net\\r\\n\"\n               b\"Connection: close\\r\\n\\r\\n\")\n\n    writer.write(request)\n    return await reader.read(-1)\n```\n\n## Why yet another SOCKS connector for aiohttp\n\nUnlike [aiosocksy](https://github.com/romis2012/aiosocksy), aiohttp_socks has only single point of integration with aiohttp. \nThis makes it easier to maintain compatibility with new aiohttp versions.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache 2",
    "summary": "Proxy connector for aiohttp",
    "version": "0.8.4",
    "project_urls": {
        "Homepage": "https://github.com/romis2012/aiohttp-socks"
    },
    "split_keywords": [
        "asyncio",
        "aiohttp",
        "socks",
        "socks5",
        "socks4",
        "http",
        "proxy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "094d9f612a7967861091913fa40caf405fbbce757d700a89e6dcb75947a4176e",
                "md5": "88d1bc5b3117ab6f93d54138ad4f5c62",
                "sha256": "e16ae289627fd190394def272189d82c85658520509c04561e9b4f272ec68edf"
            },
            "downloads": -1,
            "filename": "aiohttp_socksx-0.8.4.tar.gz",
            "has_sig": false,
            "md5_digest": "88d1bc5b3117ab6f93d54138ad4f5c62",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10063,
            "upload_time": "2023-11-14T19:54:37",
            "upload_time_iso_8601": "2023-11-14T19:54:37.443170Z",
            "url": "https://files.pythonhosted.org/packages/09/4d/9f612a7967861091913fa40caf405fbbce757d700a89e6dcb75947a4176e/aiohttp_socksx-0.8.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-14 19:54:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "romis2012",
    "github_project": "aiohttp-socks",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "aiohttp-socksx"
}
        
Elapsed time: 0.21051s