Im running python 2.7
import requests
count = 1000
while count <= 10000:
count += 1
user = requests.get("https://api.roblox.com/Users/" + str(count)).json() ['Username']
print (user)
Thanks!
Use Python's with, to open your output file, this way the file is automatically closed afterwards. Secondly, it makes more sense to use range() to give you all of your numbers, and format can be used to add the number to your URL as follows:
import requests
with open('output.txt', 'w') as f_output:
for count in range(1, 10000 + 1):
user = requests.get("https://api.roblox.com/Users/{}".format(count)).json()['Username']
print(user)
f_output.write(user + '\n')
Each entry is then written to the file with a newline after each.
fo.close()with, avoiding exception-related issues.