我想查看此网站是否在线。
import http.client
c = http.client.HTTPConnection("https://support.binance.com/hc/en-us/categories/115000056351")
c.request("HEAD", "/index.html")
print (c.getresponse().status)
代码适用于
c = http.client.HTTPConnection("www.google.com")
答案 0 :(得分:1)
您可以尝试使用requests
。如果状态代码为200,则表示该站点在线
In [20]: import requests
In [21]: req = requests.get('https://support.binance.com/hc/en-us/categories/115000056351')
In [22]: req
Out[22]: <Response [200]>