when I use the proxy option for client get method, I got 'Constructor parameter must be string'
Code ist simple
async def run(self, proxy):
proxy_for_requests = {'https': proxy}
try:
async with aiohttp.ClientSession() as session:
async with session.get(url='https://www.google.com', proxy=proxy_for_requests,
timeout=5, headers=self.get_headers()) as resp:
return proxy
except Exception as e:
print(str(e))
return None
Expected: When it's a timeout problem, it returns None.
Actual: this function always raises the error: "Constructor parameter should be str". I removed the option timeout and headers, but it still the same case. Only when I left the only option url, it can run correctly. It seems the options for this session.get are not available.
my aiohttp is 3.4.4 and my OS is windows 10.
GitMate.io thinks the contributor most likely able to help you is @asvetlov.
Possibly related issues are https://github.com/aio-libs/aiohttp/issues/1455 (How to use Proxy?), https://github.com/aio-libs/aiohttp/issues/1167 (Client session method that accepts http verb as a parameter), https://github.com/aio-libs/aiohttp/issues/1293 (Use timeout in client), https://github.com/aio-libs/aiohttp/issues/3385 (Disable body parameter in HTTPException constructor), and https://github.com/aio-libs/aiohttp/issues/499 (Url GET parameters are lost when redirecting).
I found the error, I passed an argument format as the python requests, so basically I passed a dictionary object. When I changed it to string, everything worked fine. But it seems it does not work work with https. I hope you guys can make a update for this.
So maybe raise an error to say that the proxy argument format is not correct rather than let the yarl URL do the job?