0

I'm creating script which will tell us is website is down or up. But I got error HTTPSConnectionPool(host='gooogle.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError("hostname 'gooogle.com' doesn't match 'www.google.com'")))

here is my code:

import requests

website_url = input("Enter a website url: ")

r = requests.get(f'https://{website_url}', timeout=5)

if r.status_code != 200:    
    print(f"uh no, {website_url} is down")
else:
    print(f"Good News, {website_url} is up")

I am using the requests module for this. To be honest, I don't know how to check the website is down or up but still, I write this code if you know how please answer me with details.

2
  • 2
    Well, yes; google has two os in it, not three. Commented Oct 19, 2021 at 11:24
  • Did you try any URLs other than google? This seems like an issue with the difference between "www.google.com" and "google.com". Commented Oct 19, 2021 at 11:24

1 Answer 1

3

First of all, you're referring to https://www.gooogle.com instead of https://www.google.com; which I assume is the webpage that you want to test.

Regarding the reason of your error:

Since you're accessing with the HTTPS protocol, you will check the certificates of the destination server, in order to verify that this one is who is supposed to be.

Apparently, the domain https://www.gooogle.com is offering the same certificate than https://www.google.com, and also it performs a redirect to it, but that domain isn't included in the Subject Alternate Name (SAN) of the Google certificate, so actually you cannot verify the authenticity of the accessed domain.

If you use your code against a site that has correctly set the SSL verification, it should work without problems. On another hand, if you just want to check if a site is UP or DOWN independently on its SSL configuration, you can just pass the flag verify set to False:

requests.get(f'https://{website_url}', verify=False, timeout=5)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.