-2

I am going through a list of websites and checking if they are alive. Originally I was using urllib but it was getting blocked at times. I switched to using a ping but even with ping sometimes I get "request timed out" even though the website is online when I visit it through my browser. Is there a reliable way to check if a website is alive?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
squidg
  • 451
  • 6
  • 17
  • What is your criteria for "a website is alive"? ``ping`` does not ensure a host actually serves a valid website, only that it is reachable with a protocol that is not HTTP/HTTPS. – MisterMiyagi Sep 14 '20 at 16:02

1 Answers1

-1

You could use the requests module

import requests

try:
    r = requests.get(url)
except:
    print("Website is down")
  • What if the website redirects you to one of those "buy this domain" pages? This is not a reliable way to see if the website is down. The linked duplicate has the correct answer. – Pranav Hosangadi Sep 14 '20 at 16:28