How to get the full url from only the domain name python

I am making a database for training a neural network. For that database I need a lot of safe websites. I searched on the internet for such a database but all the databases only give out the subdomain names. So I tried getting the url from the subdomain name. Like from google.com I want https://www.google.com. But there is no source about how to do that.

I tried to kind of brute force it by checking if the website existed, but I just got a ton of error codes.

for domain in f:
    response = requests.get(f'{domain}', verify=False)
    if response.status_code == 200:
        Goodwebsites.write(f'{domain})
        continue
    response = requests.get(f'{domain}, verify=False)
    if response.status_code == 200:
        Goodwebsites.write(f'{domain})
        continue
    response = requests.get(f'{domain}, verify=False)
    if response.status_code == 200:
        Goodwebsites.write(f'{domain})
        continue
    response = requests.get(f'{domain}, verify=False)
    if response.status_code == 200:
        Goodwebsites.write(f'{domain}")
        continue

I couldn’t add the actual links because it was marked as spam, but imagine that before the domain I added http, https and/or www
Is there a better way to get the url from the subdomain or is there a better database?

Leave a Comment