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!
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 the open file, in with statement as this:
import requests
count = 1000
with open('output.txt', 'w') as f:
while count <= 10000:
count += 1
user = requests.get("https://api.roblox.com/Users/" + str(count)).json()['Username']
print (user)
f.write(user + '\n')
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.