I am using the requests module in python to check if an Instagram username is available.
Basically, I add the username in the URL, like so: https://instagram.com/user, with "user" being a variable. However, as soon as I test it out, the function status_code gives me HTTP error 429. I know that error 429 occurs after sending too many requests; but I have tried again with a 48 hour time difference, just to get the same error after one single request.
I have tried the same code with Twitter and it works perfectly fine (even with 20k+ requests in around 2 hours).
Also, using a VPN did not solve the problem.
Could anyone suggest any help? It would be very much appreciated.
Here is the code:
import requests
cnt=0 #counts words
#MAKES WORD LIST
f=open(r'C:\Users\hugop\OneDrive\python\sm_name_checker\dicos\dico_francais_clean.txt',"r")#french dictionnary
content_raw = f.read()
content = list(content_raw.split("\n"))
f.close()
#WRITES AVAILABLE NAMES
g=open(r'C:\Users\hugop\OneDrive\python\sm_name_checker\available_names.txt',"w")#available names will be written into this text doc
for word in content:
cnt += 1
f = requests.get("https://instagram.com/{}".format(word))
print (cnt, word, f.status_code)
if f.status_code != 200: #200 means the page exists and has been accessed
g.write("{} {} {}\n".format(cnt, word, f.status_code))
input()