import requests
import json
import time
f = open('ok.txt', 'r')
c = f.read()
r = []
start = time.perf_counter()
def steamCheck(name):
return requests.get("https://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=removed&vanityurl=%s" % (name)).json()
for word in c.split():
p = steamCheck(word)
if p['response']['success'] == 42:
with open('www.txt', 'a') as save:
save.write(word + '\n')
print('%s is available' % (word))
r.append(word)
else:
print('%s is taken' % (word))
finish = time.perf_counter()
print(f'Finished in {round(finish-start, 2)} second(s)')
Hi this is a script I made to check if each word from a list exists as a vanityurl on steam or not. I removed the api key so if you wanted to test yourself you would have to get one here : https://steamcommunity.com/dev/apikey
I am a beginner in python and would like to know how you would change my script to make it better (faster, cleaner, etc..). So far it works as intended however it is fairly slow and believe I may be doing something inefficiently. Thanks for any advice you may have.
Example response from api if url is not taken:
{'response': {'success': 42, 'message': 'No match'}}
Example if the url IS taken:
{"response": {"steamid": "76561198868XXXXXX", "success": 1}}