2

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

1 Answers1

1

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]>
  • Thank you for your answer, it works but with other method i can check 1000 sites in 1 minute, with request just 100 sites in 1 minute. Have you any proposal for that? @GeorgeDragan – Kağan Örün Feb 23 '18 at 18:22
  • 1
    If you need just the status code you can use `requests.head('https://support.binance.com/hc/en-us/categories/115000056351')`. It is the same http method that you used with `http.client`. It will return only the response headers and not the entire HTML. Alternatively you can have a look at [pycurl](http://pycurl.io/) I think is faster then `requests` or even `curl` if you are using a Linux machine. – George Dragan Feb 23 '18 at 21:05