0

I'm new to python and working on a python project that checks username availability on Ubisoft.com. I'm trying to do this by entering a wordlist of possible usernames and letting the code check wether the site gives a 200- or a 404 status code, with 404 being a Unavailable username and 200 an Available username. When I run the code I get this traceback error message:

 File "C:\Users\Gibbo\OneDrive\Bureaublad\uPlay\usernamess.py", line 7, in <module>
   response = urllib.response.status_code("https://ubisoftconnect.com/en-US/profile/")
AttributeError: module 'urllib.response' has no attribute 'status_code'

And here's the code I've made

import datetime
import urllib.request
import urllib
import requests

url = "https://ubisoftconnect.com/en-US/profile/"
response = urllib.response.status_code("https://ubisoftconnect.com/en-US/profile/")

print(r.status_code)

url = 'https://ubisoftconnect.com/en-US/profile/'
available = "available.txt"
users = "usernames.txt"
now = datetime.datetime.now ()
if response.status_code == 200:
    print('Available')
elif response.status_code == 404:
    print('Unavailable')


def initialize():
    ascii_banner = pyfiglet.figlet_format("Made  By  Gxzs!!")
    print(ascii_banner)
    print(f"{count()} usernames detected")
    print("Press ENTER to begin checking")
    input("")
    check()

I'm fairly new to Python coding so I was not able to try out things myself

1 Answer 1

0

urllib and requests are two separate packages, but you seem to be mixing them together. Here are how to get the status code from both of them on their own:

Using urrllib

import urllib.request

response = urllib.request.urlopen("https://ubisoftconnect.com/en-US/profile/")
status_code = response.getcode()

Using requests

import requests

response = requests.get("https://ubisoftconnect.com/en-US/profile/")
status_code = response.status_code
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.