Answer the question
In order to leave comments, you need to log in
AioHttp error Cannot connect to host *site here*:443 ssl:None [Connect call failed ('*his ip*', 443)]?
There are many urls. You need to make inquiries. Function for requests:
async def get_html_2(session, url):
try:
async with session.get(url) as response:
return await response.text()
except Exception as e:
print(url, e)
async def html_get(url):
async with aiohttp.ClientSession() as session:
html = await get_html_2(session, url)
return html
loop = asyncio.get_event_loop()
result.append(asyncio.ensure_future(html_get(BASE_URL.format(urllib.parse.quote(j[0]))))) # это проходит в цикле, поэтому
# формируется урлов много. сам цикл здесь пропустил
result = loop.run_until_complete(asyncio.gather(*result))
Answer the question
In order to leave comments, you need to log in
When using WINDOWS with python>=3.8, aiohttp<=3.7.4 with proxy, the error "... Cannot connect to host *website here*:443 ssl:default ..." can be solved like this:
import sys
if sys.version_info[0] == 3 and sys.version_info[1] >= 8 and sys.platform.startswith('win'):
policy = asyncio.WindowsSelectorEventLoopPolicy()
asyncio.set_event_loop_policy(policy)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question