57 lines
1.9 KiB
Markdown
57 lines
1.9 KiB
Markdown
# Stat Check Elo Scraper
|
|||
|
|
|
||
|
|
This is a pure-Python scraper for the public Excel workbook embedded at:
|
||
|
|
|
||
|
|
`https://www.stat-check.com/elo`
|
||
|
|
|
||
|
|
It does not need Selenium, Playwright, Chromium, pandas, or openpyxl. It uses only the Python standard library.
|
||
|
|
|
||
|
|
## How It Works
|
||
|
|
|
||
|
|
The Stat Check page embeds a public OneDrive Excel workbook through a `1drv.ms` URL. Microsoft's web viewer does not expose a stable direct `.xlsx` URL in the page HTML, but it does use a public OneDrive metadata API behind the scenes.
|
||
|
|
|
||
|
|
The scraper reproduces the useful part of that flow:
|
||
|
|
|
||
|
|
1. Request an anonymous Microsoft "Badger" token from:
|
||
|
|
`https://api-badgerp.svc.ms/v1.0/token`
|
||
|
|
2. Convert the public OneDrive embed URL into Microsoft Graph's `shares/u!...` id format.
|
||
|
|
3. Call:
|
||
|
|
`https://my.microsoftpersonalcontent.com/_api/v2.0/shares/{share_id}/driveItem?action=EmbedView`
|
||
|
|
with `Authorization: Badger <token>`.
|
||
|
|
4. Read `@content.downloadUrl` from the metadata response.
|
||
|
|
5. Download the real `.xlsx`.
|
||
|
|
6. Convert the first worksheet to CSV by reading the XLSX ZIP/XML structure directly.
|
||
|
|
|
||
|
|
The Microsoft endpoints used here are undocumented and could change, but this currently works without browser automation.
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
```bash
|
||
|
|
python3 pure_python_elo_scrape.py
|
||
|
|
```
|
||
|
|
|
||
|
|
Default outputs:
|
||
|
|
|
||
|
|
- `elo-pure.xlsx`
|
||
|
|
- `elo-pure.csv`
|
||
|
|
|
||
|
|
You can also pass output paths:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
python3 pure_python_elo_scrape.py statcheck-elo.xlsx statcheck-elo.csv
|
||
|
|
```
|
||
|
|
|
||
|
|
## Files
|
||
|
|
|
||
|
|
- `pure_python_elo_scrape.py` - gets the Badger token, resolves the workbook download URL, downloads the XLSX, writes CSV.
|
||
|
|
- `download_and_parse.py` - helper functions for downloading and converting XLSX to CSV with stdlib only.
|
||
|
|
- `sample-elo.csv` - sample output captured during testing.
|
||
|
|
|
||
|
|
## Verification From Testing
|
||
|
|
|
||
|
|
On June 28, 2026, this downloaded a `3,465,320` byte workbook and produced a `4,145,399` byte CSV with `40,945` rows. The CSV header was:
|
||
|
|
|
||
|
|
```csv
|
||
|
|
Rank,Delta,Name,W,L,D,G,WR%,Elo,Delta,Last Event,Country
|
||
|
|
```
|