parse leetcode by graphql
import requests # Define the endpoint and headers url = "https://leetcode.com/graphql" headers = { "Content-Type": "application/json", "User-Agent": "Mozilla/5.0" # This is just an example, use your own user agent or any generic one } # Define the query and variables username = "googlewaitme" data = { "query": """ query recentAcSubmissions($username: String!, $limit: Int!) { recentAcSubmissionList(username: $username, limit: $limit) { id title titleSlug timestamp } } """, "variables": { "username": username, "limit": 15 } } # Make the POST request response = requests.post(url, json=data, headers=headers) if response.status_code == 200: response_data = response.json() print(response_data) else: print(f"Error {response.status_code}: {response.text}")
Leave a Comment