dimanche 19 septembre 2021

check website is valid or not through python

I have 1000 website list to check weather its exist or not but my code is showing all correct which is starting with https:// here is below my code

from urllib.request import Request, urlopen




from urllib.error import URLError, HTTPError
req = Request("http://stackoverflow.com")
try:
    response = urlopen(req)
except HTTPError as e:
    print('The server couldn\'t fulfill the request.')
    print('Error code: ', e.code)
except URLError as e:
    print('We failed to reach a server.')
    print('Reason: ', e.reason)
else:
    print ('Website is working fine')



Aucun commentaire:

Enregistrer un commentaire