aiohttp-socks-0.7.1
توضیحات
Proxy connector for aiohttp
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | aiohttp-socks-0.7.1 |
| نام | aiohttp-socks |
| نسخه کتابخانه | 0.7.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Roman Snegirev |
| ایمیل نویسنده | snegiryev@gmail.com |
| آدرس صفحه اصلی | https://github.com/romis2012/aiohttp-socks |
| آدرس اینترنتی | https://pypi.org/project/aiohttp-socks/ |
| مجوز | Apache 2 |
## aiohttp-socks
[](https://travis-ci.com/github/romis2012/aiohttp-socks)
[](https://coveralls.io/github/romis2012/aiohttp-socks?branch=master)
[](https://badge.fury.io/py/aiohttp-socks)
[](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, 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.
نیازمندی
| مقدار | نام |
|---|---|
| >=2.3.2 | aiohttp |
| >=19.2.0 | attrs |
| <3.0.0,>=2.0.0 | python-socks[asyncio] |
نحوه نصب
نصب پکیج whl aiohttp-socks-0.7.1:
pip install aiohttp-socks-0.7.1.whl
نصب پکیج tar.gz aiohttp-socks-0.7.1:
pip install aiohttp-socks-0.7.1.tar.gz