| src | ||
| .env.example | ||
| .gitignore | ||
| Cargo.toml | ||
| README.md | ||
VJudge Leaderboard Scraper
A Rust tool that fetches contest data from VJudge and writes it to a Google Spreadsheet with proper formatting.
Features
- Fetches leaderboard data from VJudge contests
- Processes submissions to calculate AC/WA status and attempt counts
- Writes formatted data to Google Spreadsheet with:
- Exercise names (A, B, C, ... Z, AA, AB, ...)
- User names
- Green cells for AC submissions (with retry count if > 1)
- Red cells for WA submissions (with attempt count)
Setup
1. Install Rust
If you don't have Rust installed, get it from rustup.rs
2. Google Service Account Setup
-
Enable Google Sheets API in Google Cloud Console via this link: https://console.cloud.google.com/marketplace/product/google/sheets.googleapis.com
-
Go to API > Credentials and go to Manage service accounts.
-
Create a service account then manage its keys. Create a new key with type JSON and download it
-
Put the downloaded
.jsonfile in the root folder of this project and rename it toservice_account.json -
Go to your own sheet and then add the read permission to that service account via its email.
3. Set Environment Variable
Linux/MacOS (Bash/Zsh):
# Export the service account key as an environment variable
export GOOGLE_SERVICE_ACCOUNT_KEY=$(cat path/to/your/service-account-key.json)
Windows (PowerShell):
# Export the service account key as an environment variable
$env:GOOGLE_SERVICE_ACCOUNT_KEY = Get-Content path\to\your\service-account-key.json -Raw
Windows (CMD):
# Note: For CMD, it's easier to use PowerShell or set the variable manually
set /p GOOGLE_SERVICE_ACCOUNT_KEY=<path\to\your\service-account-key.json
Or set directly (all platforms):
# Linux/MacOS
export GOOGLE_SERVICE_ACCOUNT_KEY='{"type":"service_account","project_id":"...","private_key_id":"...","private_key":"...","client_email":"...","client_id":"...","auth_uri":"...","token_uri":"...","auth_provider_x509_cert_url":"...","client_x509_cert_url":"..."}'
# Windows PowerShell
$env:GOOGLE_SERVICE_ACCOUNT_KEY = '{"type":"service_account","project_id":"...","private_key_id":"...","private_key":"...","client_email":"...","client_id":"...","auth_uri":"...","token_uri":"...","auth_provider_x509_cert_url":"...","client_x509_cert_url":"..."}'
Usage
cargo run --release <contest_id> <spreadsheet_id> <sheet_name>
Example
cargo run --release 763656 1abc_your_spreadsheet_id_xyz Sheet1
Where:
763656is the VJudge contest ID (from URL:https://vjudge.net/contest/763656)1abc_your_spreadsheet_id_xyzis your Google Spreadsheet ID from the URL:https://docs.google.com/spreadsheets/d/1abc_your_spreadsheet_id_xyz/edit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is your spreadsheet IDSheet1is the name of the sheet/tab within the spreadsheet (must exist, or the program will abort)
Output Format
The spreadsheet will be formatted as:
| Name | A | B | C | ... |
|---|---|---|---|---|
| User 1 | AC | AC (2) | -3 | ... |
| User 2 | -1 | AC | ... |
Where:
- Green cells: AC submissions
AC: Accepted on first tryAC (n): Accepted after n wrong attempts
- Red cells: Wrong Answer
-n: n wrong attempts, not yet accepted
- Empty cells: No submission
Submission Status Codes
0: Wrong Answer (WA)1: Accepted (AC)2: Other (ignored)