| @@ -142,7 +142,6 @@ aiohttp usage | |||||
| import asyncio | import asyncio | ||||
| import aiohttp | import aiohttp | ||||
| import aiosocks | import aiosocks | ||||
| from yarl import URL | |||||
| from aiosocks.connector import ProxyConnector, ProxyClientRequest | from aiosocks.connector import ProxyConnector, ProxyClientRequest | ||||
| @@ -160,19 +159,19 @@ aiohttp usage | |||||
| try: | try: | ||||
| with aiohttp.ClientSession(connector=conn, request_class=ProxyClientRequest) as session: | with aiohttp.ClientSession(connector=conn, request_class=ProxyClientRequest) as session: | ||||
| # socks5 proxy | # socks5 proxy | ||||
| async with session.get('http://github.com/', proxy=URL('socks5://127.0.0.1:1080'), | |||||
| async with session.get('http://github.com/', proxy='socks5://127.0.0.1:1080', | |||||
| proxy_auth=auth5) as resp: | proxy_auth=auth5) as resp: | ||||
| if resp.status == 200: | if resp.status == 200: | ||||
| print(await resp.text()) | print(await resp.text()) | ||||
| # socks4 proxy | # socks4 proxy | ||||
| async with session.get('http://github.com/', proxy=URL('socks4://127.0.0.1:1081'), | |||||
| async with session.get('http://github.com/', proxy='socks4://127.0.0.1:1081', | |||||
| proxy_auth=auth4) as resp: | proxy_auth=auth4) as resp: | ||||
| if resp.status == 200: | if resp.status == 200: | ||||
| print(await resp.text()) | print(await resp.text()) | ||||
| # http proxy | # http proxy | ||||
| async with session.get('http://github.com/', proxy=URL('http://127.0.0.1:8080'), | |||||
| async with session.get('http://github.com/', proxy='http://127.0.0.1:8080', | |||||
| proxy_auth=ba) as resp: | proxy_auth=ba) as resp: | ||||
| if resp.status == 200: | if resp.status == 200: | ||||
| print(await resp.text()) | print(await resp.text()) | ||||