V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
2033009565
V2EX  ›  问与答

Python aiohttp 访问 twitter 关于 ssl 问题

  •  1
     
  •   2033009565 · 2020-08-13 16:29:44 +08:00 · 2644 次点击
    这是一个创建于 1342 天前的主题,其中的信息可能已经有所发展或是发生改变。

    代码如下: 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 条回复    2020-08-19 09:26:59 +08:00
    2033009565
        1
    2033009565  
    OP
       2020-08-13 16:41:29 +08:00
    重新排版
    2033009565
        2
    2033009565  
    OP
       2020-08-13 16:44:36 +08:00
    排版好重新发
    est
        3
    est  
       2020-08-13 16:44:52 +08:00
    ssl:default [信号灯超时时间已到]

    建议联系信号灯生产厂家售后。
    2033009565
        4
    2033009565  
    OP
       2020-08-13 16:55:28 +08:00
    直接上传图片:
    2033009565
        5
    2033009565  
    OP
       2020-08-13 16:55:54 +08:00
    网上搜索说将 verify_ssl=Fals 或者添加 connector=aiohttp.TCPConnector(limit=50, loop=loop) 还是一样出错
    junnplus
        6
    junnplus  
       2020-08-13 18:51:47 +08:00
    我试了下没啥问题,先确认下终端是否可以直接 ping 通
    2033009565
        7
    2033009565  
    OP
       2020-08-14 11:52:56 +08:00
    @junnplus
    大佬 ,我这边 ping 的时候显示超时,但网页是可以正常访问的,这和我使用的 vpn 有关吗?
    junnplus
        8
    junnplus  
       2020-08-14 14:52:19 +08:00
    @2033009565 你可能需要设置 aiohttp 的代理
    2033009565
        9
    2033009565  
    OP
       2020-08-19 09:26:59 +08:00
    @junnplus 好的 谢谢 我去试试
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1241 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:07 · PVG 02:07 · LAX 11:07 · JFK 14:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.