Skip to content

Instantly share code, notes, and snippets.

@useraid
Created February 18, 2024 05:49
Show Gist options
  • Save useraid/154844af6b86c42b224b270f8c535262 to your computer and use it in GitHub Desktop.
Save useraid/154844af6b86c42b224b270f8c535262 to your computer and use it in GitHub Desktop.
Pulls Leetcode stats and save it to file
import requests
username = "useraid"
url = f"https://leetcode-api-faisalshohag.vercel.app/{username}"
response = requests.get(url)
data = response.json()
with open("lc", "w") as file:
file.write(f"Total Solved: {data['totalSolved']}\n")
file.write(f"Ranking: {data['ranking']}\n")
file.write(f"Contribution Point: {data['contributionPoint']}\n")
file.write(f"Reputation: {data['reputation']}\n")
file.write("\nTotal Submissions:\n")
for submission in data['totalSubmissions']:
file.write(f"Difficulty: {submission['difficulty']}, Count: {submission['count']}, Submissions: {submission['submissions']}\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment