aiohttp-socks


Nameaiohttp-socks JSON
Version 0.8.4 PyPI version JSON
download
home_pagehttps://github.com/romis2012/aiohttp-socks
SummaryProxy connector for aiohttp
upload_time2023-10-03 08:02:56
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-socks",
    "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/22/be/df389469083cba73df69d1cef68056d7ce2bda76ced3d023dd75493558f5/aiohttp_socks-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\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": "3f81cae77c14d88f5300b698c9ce39ae596605689b928495f1e66ec5648ad4b2",
                "md5": "59366899749459859f0bb870e0def354",
                "sha256": "74b21105634ed31d56ed6fee43701ca16218b53475e606d56950a4d17e8290ea"
            },
            "downloads": -1,
            "filename": "aiohttp_socks-0.8.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "59366899749459859f0bb870e0def354",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9626,
            "upload_time": "2023-10-03T08:02:54",
            "upload_time_iso_8601": "2023-10-03T08:02:54.681046Z",
            "url": "https://files.pythonhosted.org/packages/3f/81/cae77c14d88f5300b698c9ce39ae596605689b928495f1e66ec5648ad4b2/aiohttp_socks-0.8.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "22bedf389469083cba73df69d1cef68056d7ce2bda76ced3d023dd75493558f5",
                "md5": "3ca4d981d26d2a3e7d1b7afde17e75a2",
                "sha256": "6b611d4ce838e9cf2c2fed5e0dba447cc84824a6cba95dc5747606201da46cb4"
            },
            "downloads": -1,
            "filename": "aiohttp_socks-0.8.4.tar.gz",
            "has_sig": false,
            "md5_digest": "3ca4d981d26d2a3e7d1b7afde17e75a2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8510,
            "upload_time": "2023-10-03T08:02:56",
            "upload_time_iso_8601": "2023-10-03T08:02:56.623733Z",
            "url": "https://files.pythonhosted.org/packages/22/be/df389469083cba73df69d1cef68056d7ce2bda76ced3d023dd75493558f5/aiohttp_socks-0.8.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-03 08:02:56",
    "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-socks"
}
        
Elapsed time: 0.25611s