简体   繁体   中英

python3 http.client i cant use for not www sites

I want to check this site is online or not.

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)

Code is working for

c = http.client.HTTPConnection("www.google.com")

You can try using requests . If the status code is 200 it means the site is online

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]>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM