2033009565
V2EX  ›  问与答

Python aiohttp 访问 twitter 关于 ssl 问题

  •  1
     
  •   2033009565 · Aug 13, 2020 · 3998 views
    This topic created in 2274 days ago, the information mentioned may be changed or developed.

    代码如下: import aiohttp import ssl import certifi import asyncio user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36' headers={ 'user_agent':user_agent }

    async def test(): async with aiohttp.ClientSession() as session: async with session.get(url='https://www.facebook.com/',headers=headers,) as response: print(await response.text()) loop=asyncio.get_event_loop() loop.run_until_complete(test()) 出现如下报错: aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host www.facebook.com:443 ssl:default [信号灯超时时间已到] 网上搜索说将 verify_ssl=Fals 或者添加 connector=aiohttp.TCPConnector(limit=50, loop=loop) 还是一样出错

    9 replies  •  2020-08-19 09:26:59 +08:00
    2033009565
    2033009565
    OP
    Aug 13, 2020
    1
    重新排版
    2033009565
    2033009565
    OP
    Aug 13, 2020
    2
    排版好重新发
    est
    est
    Aug 13, 2020
    3
    ssl:default [信号灯超时时间已到]

    建议联系信号灯生产厂家售后。
    2033009565
    2033009565
    OP
    Aug 13, 2020
    4
    直接上传图片:
    2033009565
    2033009565
    OP
    Aug 13, 2020
    5
    网上搜索说将 verify_ssl=Fals 或者添加 connector=aiohttp.TCPConnector(limit=50, loop=loop) 还是一样出错
    junnplus
    junnplus
    Aug 13, 2020
    6
    我试了下没啥问题,先确认下终端是否可以直接 ping 通
    2033009565
    2033009565
    OP
    Aug 14, 2020
    7
    @junnplus
    大佬 ,我这边 ping 的时候显示超时,但网页是可以正常访问的,这和我使用的 vpn 有关吗?
    junnplus
    junnplus
    Aug 14, 2020
    8
    @2033009565 你可能需要设置 aiohttp 的代理
    2033009565
    2033009565
    OP
    Aug 19, 2020
    9
    @junnplus 好的 谢谢 我去试试
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4881 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 09:24 · PVG 17:24 · LAX 01:24 · JFK 04:24
    ♥ Do have faith in what you're doing.