Skip to content

Instantly share code, notes, and snippets.

@sophiezhng
Last active January 24, 2021 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sophiezhng/172d2e0584d348bb375c8207152e6c9f to your computer and use it in GitHub Desktop.
Save sophiezhng/172d2e0584d348bb375c8207152e6c9f to your computer and use it in GitHub Desktop.
Check MySpace Windows 93's top 100 users with the most fwiends
import json
import requests
import time
limit = 100
# Write is formatted for .md files
path_to_file = "/Users/user/your/path/to/file"
def main():
sorted_users = get_users()
f = open(path_to_file, "w")
count = 1
f.write("Last updated: {{ \"now\" | date: site.date_format }}\n\nPlace | Name | Country | # of Fwiends\n| --- | --- | --- | --- |\n")
for item in sorted_users[:limit]:
time.sleep(11)
r = requests.get('https://myspace.windows93.net/api.php?id='+item[0])
check_stat(r)
user = r.json()
f.write("\#"+str(count)+" | "+user["name"]+" | "+user["country"]+" | "+str(item[1]["fwiends"])+"\n")
print(item,", ", count)
count+=1
f.write("\nFork the source code [here](https://gist.github.com/sophiezhng/172d2e0584d348bb375c8207152e6c9f)")
f.close()
print("LOADING INTO FILE COMPLETE")
def get_users():
r = requests.get('https://myspace.windows93.net/api.php')
check_stat(r)
json = r.json()["fwiends"]
sorted_list = sorted(json.items(), key=lambda x: x[1]["fwiends"], reverse=True)
return sorted_list[:limit]
def check_stat(request):
if request.json()["success"] == False:
print("ERROR")
exit(1)
if __name__ == "__main__":
main()
import json
import requests
import time
# Limit for # of users on leaderboard
limit = 100
def main():
sorted_users = get_users()
leaderboard = []
count = 1
print("Place | Name | Country | # of Fwiends")
print("| --- | --- | --- | --- |")
for item in sorted_users[:limit]:
time.sleep(11)
r = requests.get('https://myspace.windows93.net/api.php?id='+item[0])
check_stat(r)
user = r.json()
leaderboard.append(user["name"])
print("#",count," | "+user["name"]+" | "+user["country"]+" | ",item[1]["fwiends"],sep='')
count+=1
def get_users():
r = requests.get('https://myspace.windows93.net/api.php')
check_stat(r)
json = r.json()["fwiends"]
sorted_list = sorted(json.items(), key=lambda x: x[1]["fwiends"], reverse=True)
return sorted_list[:limit]
def check_stat(request):
if request.json()["success"] == False:
print("ERROR")
exit(1)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment