I'm trying to make a program that checks username availability on Ubisoft.com.
I tried to do this by entering a profile URL letting the code check whether the site gives a 200- or a 404 status code, with 404 being a Taken username and 200 an Available username.
The problem with using a 200 status code for this is that the page that says it’s a 404 is in fact a 200 status code.
Does anyone know a way to make it print (“AVAILABLE”) if an username exists (like https://ubisoftconnect.com/en-US/profile/test) and print (“TAKEN”) if an username is taken (like https://ubisoftconnect.com/en-US/profile/test1241924)
The code I currently have and used for the 200 and 404 source code:
(urllib.request.urlopen("https://ubisoftconnect.com/en-US/profile/test1241924").getcode())
if (urllib.request.urlopen("https://ubisoftconnect.com/en-US/profile/test1241924").getcode()) == 200:
print ("TAKEN")
if (urllib.request.urlopen("https://ubisoftconnect.com/en-US/profile/test1241924").getcode()) == 404:
print ("AVAILABLE!")
Aucun commentaire:
Enregistrer un commentaire