Search code examples
pythonpython-3.xhttp-proxyaiohttp

same proxy run with requests, but do not function with aiohttp


I followed the docs aiohttp doc with Python 3.6

async with aiohttp.ClientSession() as session:
async with session.post("http://python.org", data=payload
                       proxy="http://proxy.com") as resp:
    print(resp.status)

set the proxy without authorization for my spider but it shows with code 407, the version of aiohttp is 3.5.4. the code function well without setting parameter 'proxy'

But the same proxy without authorization functions well with Requests, its version is 2.19.1. And it returns 200.

I also try the code in the answer of Andrew Svetlov but it returns

AttributeError: module 'aiohttp' has no attribute 'ProxyConnector'

I expect the same proxy function with aiohttp


Solution

  • aiohttp should be used with the original basic_auth...I found that I had changed pact of auth, however, it needs aiosocksy for socks4 over aiohttp 3.X