A VJudge leaderboard scraper written in Rust, outputs to Google Spreadsheet
Find a file
2026-01-05 16:30:20 +07:00
src Update README and main.rs to include sheet_name parameter for Google Sheets 2026-01-05 16:30:20 +07:00
.env.example Initial commit 2026-01-05 16:23:54 +07:00
.gitignore Initial commit 2026-01-05 16:23:54 +07:00
Cargo.toml Initial commit 2026-01-05 16:23:54 +07:00
README.md Update README and main.rs to include sheet_name parameter for Google Sheets 2026-01-05 16:30:20 +07:00

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

  1. Enable Google Sheets API in Google Cloud Console via this link: https://console.cloud.google.com/marketplace/product/google/sheets.googleapis.com

  2. Go to API > Credentials and go to Manage service accounts.

  3. Create a service account then manage its keys. Create a new key with type JSON and download it

  4. Put the downloaded .json file in the root folder of this project and rename it to service_account.json

  5. 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:

  • 763656 is the VJudge contest ID (from URL: https://vjudge.net/contest/763656)
  • 1abc_your_spreadsheet_id_xyz is your Google Spreadsheet ID from the URL:
    https://docs.google.com/spreadsheets/d/1abc_your_spreadsheet_id_xyz/edit
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                           This is your spreadsheet ID
    
  • Sheet1 is 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 try
    • AC (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)