I'm trying to create a program that checks a URL and returns whether the URL leads to a valid web page
I've already made such a program in c# using classes MyClient and WebClient. I can't seem to find a functioning alternative for Python and since I'm very inexperienced in the language am struggling to come up with anything myself.
import os
hostname = ("google.co.uk")
print (hostname)
response = os.system("ping -n 10 " + hostname)
print (response)
if response == 0:
print (hostname, 'is up!')
else:
print (hostname, 'is down!')
This program is close to what I'm wanting yet all it checks is whether a site is up, as far as I know it can't check specific pages.
Are there any libraries that have the functionality I'm looking for or is there a way to adapt my current code?