2

我想检查这个网站是否在线。

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")
4

1 回答 1

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]>
于 2018-02-23T14:43:16.897 回答