|
|
@@ -15,7 +15,7 @@ SOCKS proxy client for asyncio and aiohttp |
|
|
|
Dependencies |
|
|
|
------------ |
|
|
|
python 3.5+ |
|
|
|
aiohttp 2.1+ |
|
|
|
aiohttp 2.3.2+ |
|
|
|
|
|
|
|
Features |
|
|
|
-------- |
|
|
@@ -175,8 +175,10 @@ aiohttp usage |
|
|
|
proxy_auth=ba) as resp: |
|
|
|
if resp.status == 200: |
|
|
|
print(await resp.text()) |
|
|
|
except aiohttp.ProxyConnectionError: |
|
|
|
except aiohttp.ClientProxyConnectionError: |
|
|
|
# connection problem |
|
|
|
except aiohttp.ClientConnectorError: |
|
|
|
# ssl error, certificate error, etc |
|
|
|
except aiosocks.SocksError: |
|
|
|
# communication problem |
|
|
|
|
|
|
@@ -185,22 +187,3 @@ aiohttp usage |
|
|
|
loop = asyncio.get_event_loop() |
|
|
|
loop.run_until_complete(load_github_main()) |
|
|
|
loop.close() |
|
|
|
|
|
|
|
Proxy from environment |
|
|
|
^^^^^^^^^^^^^^^^^^^^^^ |
|
|
|
|
|
|
|
.. code-block:: python |
|
|
|
|
|
|
|
import os |
|
|
|
from aiosocks.connector import ProxyConnector, ProxyClientRequest |
|
|
|
|
|
|
|
os.environ['socks4_proxy'] = 'socks4://127.0.0.1:333' |
|
|
|
# or |
|
|
|
os.environ['socks5_proxy'] = 'socks5://127.0.0.1:444' |
|
|
|
|
|
|
|
conn = ProxyConnector() |
|
|
|
|
|
|
|
with aiohttp.ClientSession(connector=conn, request_class=ProxyClientRequest) as session: |
|
|
|
async with session.get('http://github.com/', proxy_from_env=True) as resp: |
|
|
|
if resp.status == 200: |
|
|
|
print(await resp.text()) |