## aiohttp-proxy
[![Build Status](https://travis-ci.org/Skactor/aiohttp-proxy.svg?branch=master)](https://github.com/Skactor/aiohttp-proxy)
[![Coverage Status](https://coveralls.io/repos/github/Skactor/aiohttp-proxy/badge.svg?branch=master)](https://coveralls.io/Skactor/aiohttp-proxy?branch=master)
[![PyPI version](https://badge.fury.io/py/aiohttp-proxy.svg)](https://badge.fury.io/py/aiohttp-proxy)
SOCKS proxy connector for [aiohttp](https://github.com/aio-libs/aiohttp). HTTP, HTTPS, SOCKS4(a) and SOCKS5(h) proxies are supported.
## Requirements
- Python >= 3.5.3
- aiohttp >= 2.3.2 # including v3.x
## Installation
```
pip install aiohttp_proxy
```
## Usage
#### aiohttp usage:
```python
import aiohttp
from aiohttp_proxy import ProxyConnector, ProxyType
async def fetch(url):
connector = ProxyConnector.from_url('http://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
# )
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_proxy import open_connection
async def fetch():
reader, writer = await open_connection(
socks_url='http://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 give aiohttp a new proxy support
First must declare, our code is based on [aiohttp-socks](https://github.com/romis2012/aiohttp-socks), thank you very much for the hard work.
But in order to more flexible support for multiple proxy methods (not just SOCKS proxy),
we decided to fork [aiohttp-socks] (https://github.com/romis2012/aiohttp-socks), which is currently based on it.
Combine with native aiohttp to provide HTTP/HTTPS proxy instead of writing troublesome discriminating code based on the type of proxy.
Raw data
{
"_id": null,
"home_page": "https://github.com/Skactor/aiohttp-proxy",
"name": "aiohttp-proxy",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "asyncio aiohttp socks socks5 socks4 http https proxy",
"author": "Skactor",
"author_email": "sk4ct0r@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/03/93/d7cc02c794a3febbbe7b0fd1b2c7cb31234b2556b9da7bee273c33ae0f6f/aiohttp_proxy-0.1.2.tar.gz",
"platform": "",
"description": "## aiohttp-proxy\n\n[![Build Status](https://travis-ci.org/Skactor/aiohttp-proxy.svg?branch=master)](https://github.com/Skactor/aiohttp-proxy)\n[![Coverage Status](https://coveralls.io/repos/github/Skactor/aiohttp-proxy/badge.svg?branch=master)](https://coveralls.io/Skactor/aiohttp-proxy?branch=master)\n[![PyPI version](https://badge.fury.io/py/aiohttp-proxy.svg)](https://badge.fury.io/py/aiohttp-proxy)\n\nSOCKS proxy connector for [aiohttp](https://github.com/aio-libs/aiohttp). HTTP, HTTPS, SOCKS4(a) and SOCKS5(h) proxies are supported.\n\n## Requirements\n- Python >= 3.5.3\n- aiohttp >= 2.3.2 # including v3.x\n\n## Installation\n```\npip install aiohttp_proxy\n```\n\n## Usage\n\n#### aiohttp usage:\n```python\nimport aiohttp\nfrom aiohttp_proxy import ProxyConnector, ProxyType\n\n\nasync def fetch(url):\n connector = ProxyConnector.from_url('http://user:password@127.0.0.1:1080')\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 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_proxy import open_connection\n\nasync def fetch():\n reader, writer = await open_connection(\n socks_url='http://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 give aiohttp a new proxy support\n\nFirst must declare, our code is based on [aiohttp-socks](https://github.com/romis2012/aiohttp-socks), thank you very much for the hard work.\n\nBut in order to more flexible support for multiple proxy methods (not just SOCKS proxy),\nwe decided to fork [aiohttp-socks] (https://github.com/romis2012/aiohttp-socks), which is currently based on it.\n\nCombine with native aiohttp to provide HTTP/HTTPS proxy instead of writing troublesome discriminating code based on the type of proxy.\n\n",
"bugtrack_url": null,
"license": "Apache 2",
"summary": "Full-featured proxy connector for aiohttp",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/Skactor/aiohttp-proxy"
},
"split_keywords": [
"asyncio",
"aiohttp",
"socks",
"socks5",
"socks4",
"http",
"https",
"proxy"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9701e97e1ca3b4ca031c54f3751a7f4b5829626c167846784202edafe2959781",
"md5": "ec3eadad19a4e487323bacabbfd20c2e",
"sha256": "b955ab883d30fd5452f6b226f0b416fc3905cc5e2b3f023b481e95664ef40667"
},
"downloads": -1,
"filename": "aiohttp_proxy-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ec3eadad19a4e487323bacabbfd20c2e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12322,
"upload_time": "2020-02-04T11:26:02",
"upload_time_iso_8601": "2020-02-04T11:26:02.769496Z",
"url": "https://files.pythonhosted.org/packages/97/01/e97e1ca3b4ca031c54f3751a7f4b5829626c167846784202edafe2959781/aiohttp_proxy-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0393d7cc02c794a3febbbe7b0fd1b2c7cb31234b2556b9da7bee273c33ae0f6f",
"md5": "d19a86c68309402d18f5145cff4c73c6",
"sha256": "4da16face2df486329f7eef36719da5c2ac7136e756574de06b428c5793b8090"
},
"downloads": -1,
"filename": "aiohttp_proxy-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "d19a86c68309402d18f5145cff4c73c6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10891,
"upload_time": "2020-02-04T11:26:04",
"upload_time_iso_8601": "2020-02-04T11:26:04.488373Z",
"url": "https://files.pythonhosted.org/packages/03/93/d7cc02c794a3febbbe7b0fd1b2c7cb31234b2556b9da7bee273c33ae0f6f/aiohttp_proxy-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-02-04 11:26:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Skactor",
"github_project": "aiohttp-proxy",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "aiohttp-proxy"
}