python3 http.client 我不能用于非 www 网站
python3 http.client i cant use for not www sites
我想检查这个网站是否在线。
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")
您可以尝试使用 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]>
我想检查这个网站是否在线。
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")
您可以尝试使用 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]>