📌  相关文章
📜  python 检查网站是否可访问 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:36.190000             🧑  作者: Mango

代码示例1
import requests

URL = "https://api.github.com"

try:
    response = requests.head(URL)
except Exception as e:
    print(f"NOT OK: {str(e)}")
else:
    if response.status_code == 200:
        print("OK")
    else:
        print(f"NOT OK: HTTP response code {response.status_code}")