This Python script allows you to fetch and search leaderboard data from GeeksforGeeks contests using cookies. It parses the contest link, extracts the necessary slug, and retrieves leaderboard information across multiple pages.
-
Python 3.x installed on your system
-
Necessary Python libraries (
requests
,json
,re
) installed. You can install them using pip:pip install requests
-
Open GeeksforGeeks Leaderboard API URL:
- Navigate to the leaderboard API URL for your contest. For example:
https://practiceapi.geeksforgeeks.org/api/latest/contest/gfg-weekly-159-rated-contest/leaderboard/?page=1
- Navigate to the leaderboard API URL for your contest. For example:
-
Open Developer Tools (F12 or Ctrl+Shift+I):
- Open your browser's developer tools by pressing F12 or Ctrl+Shift+I.
-
Navigate to the Network Tab:
- Click on the "Network" tab in the developer tools.
-
Reload the Page:
- Reload the leaderboard API URL page to capture network requests.
-
Find the API Request:
- Look for the request corresponding to
leaderboard/?page=1
in the network list. It should be listed under "Name" or "Path" columns.
- Look for the request corresponding to
-
View Request Headers:
- Click on the API request to open its details.
- Go to the "Headers" tab.
- Scroll down to find the "Cookie" section.
-
Copy Your Cookies:
- Copy the entire
Cookie
value. It should look something like:gfg_id5_identity=your_identity_value; csrftoken=your_csrf_token_value; gfg_nluid=your_nluid_value; ...
- Copy the entire
-
Paste Your Cookies in the Script:
- Open the
leaderboard_scraper.py
file. - Replace the placeholder
cookies
variable with your copied cookies (e.g.,gfg_id5_identity
,csrftoken
, etc.).
- Open the
-
Clone the repository to your local machine:
git clone https://github.com/like-rounak/gfg-leaderboad-rank-searcher.git cd gfg-leaderboad-rank-searcher
-
Run the script from the terminal:
python leaderboard_scraper.py
-
Write the
leaderboard_scraper.py
file:- Write up the variables
contest_link
,handle_name
, andtotal_pages
according to your requirements in terminal when prompted.
- Write up the variables
-
Follow the prompts in the terminal:
- Enter the contest link when prompted.
- Enter the handle name of the participant whose data you want to fetch.
- Enter the total number of pages in the leaderboard.
-
The script will fetch and display leaderboard data for the specified contest and handle name.
Here's an example of how to set up and run the script:
# Clone the repository
git clone https://github.com/like-rounak/gfg-leaderboad-rank-searcher.git
cd gfg-leaderboad-rank-searcher
# Run the script
python leaderboard_scraper.py