Skip to content

Instantly share code, notes, and snippets.

@tkgstrator
Created July 12, 2022 11:16
Show Gist options
  • Save tkgstrator/68d68a31b22172d7831175d659266fca to your computer and use it in GitHub Desktop.
Save tkgstrator/68d68a31b22172d7831175d659266fca to your computer and use it in GitHub Desktop.
SalmonStats Downloader
import requests
import os
import json
def download_results():
for offset in range(0, 92000, 200):
url = f"http://localhost:3030/v1/results?offset={offset}&limit=200"
response = requests.get(url).text
with open(f"results/{str(offset).zfill(6)}.json", "w") as f:
f.write(response)
def upload_results():
lists = sorted(os.listdir("results"))
for list in lists:
with open(f"results/{list}", "r") as f:
results = json.load(f)
url = "http://localhost:3030/v1/restore"
response = requests.post(url, json=results)
print(list, response.status_code)
# break
if __name__=="__main__":
# download_results()
upload_results()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment