【问题标题】:Automatize checking if a link is live using python使用python自动检查链接是否处于活动状态
【发布时间】:2021-08-26 09:20:26
【问题描述】:

我需要经常手动检查某些链接是否有效。为了避免这种情况,我想编写一个只返回所有链接的 https 状态的小脚本,这样我就可以立即看到任何 404。问题是我不知道我在做什么我只知道它应该是可能的:D

我尝试使用 python 的请求在测试页面上执行此操作,但出现以下错误

import requests

requests.get('https://exp04.zih.tu-dresden.de/')

HTTPSConnectionPool(host='exp04.zih.tu-dresden.de', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)')))

我了解错误消息的各个单词,但现在对服务器/客户端的内容一无所知。如何返回此页面的状态码?

【问题讨论】:

    标签: python https python-requests


    【解决方案1】:
    import requests
    
    requests.get('https://exp04.zih.tu-dresden.de/', verify=False)
    

    忽略 SSL 证书验证。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-11
      • 2019-12-10
      • 2012-06-02
      • 2014-05-24
      • 2013-04-06
      • 1970-01-01
      相关资源
      最近更新 更多