Skip to content
This repository was archived by the owner on Apr 22, 2026. It is now read-only.

Repository files navigation

LigaPrice

Scraper to fetch Magic: The Gathering card prices from LigaMagic website.

Usage

python main.py decklistfile outputfile.csv [batch_size]

Example

python main.py decklist.txt output.csv 5

Decklist Format

One card per line, optionally with edition in brackets:

Act of Treason [GTC]
Act of Treason [M10]
Ajani's Presence
Arcanist's Owl [NEC]

The script automatically removes:

  • Empty lines
  • Duplicates (same card + same edition)

Output Format (CSV)

name,edition,min_price,avg_price,max_price,observation
Act of Treason,GTC,0.05,0.32,1.13,
Ajani's Presence,JOU,0.08,0.53,1.99,
Act of Treason,,0.05,0.34,1.25,Edition [M10] not found

Configuration

Settings can be adjusted in config.py:

  • BATCH_SIZE: Number of cards per batch (default: 5)
  • SLEEP_BETWEEN_REQUESTS: Sleep between individual requests (default: 0.3s)
  • SLEEP_BETWEEN_BATCHES: Sleep between batches (default: 1.0s)
  • SLEEP_AFTER_429: Sleep after 429 error (default: 2.0s)
  • PROGRESSIVE_SLEEP_START_BATCH: Batch from which sleep increases (default: 7)
  • PROGRESSIVE_SLEEP_MULTIPLIERS: Progressive multipliers (1.5x, 2.0x, 2.5x)

Rate Limiting

The script implements progressive rate limiting control:

  • Batches 1-6: Normal sleep between batches (1.0s)
  • Batches 7-10: Sleep increased by 1.5x (1.5s)
  • Batches 11-15: Sleep increased by 2.0x (2.0s)
  • Batches 16+: Sleep increased by 2.5x (2.5s)

Cards that receive a 429 error are automatically added to a retry queue and reprocessed sequentially at the end, one at a time.

Logs

The script generates simplified logs:

  • Batch: Start and end of each batch
  • Cards: One log per card with result:
    • Success: [YYYY-MM-DD HH:MM:SS] Card Name [EDITION] - Min R$ X.XX, Avg R$ X.XX, Max R$ X.XX
    • Error: [YYYY-MM-DD HH:MM:SS] Card Name [EDITION] - ERROR: error message
  • Retry: Logs for reprocessing cards with 429 error

Dependencies

  • requests>=2.31.0

Features

  • Search prices for multiple editions of the same card
  • Parallel processing in batches with threads
  • Progressive rate limiting control
  • Automatic retry system for 429 errors
  • Automatic duplicate removal
  • Automatic edition detection when not specified
  • Simplified and informative logs
  • Robust error handling
  • Intelligent card grouping by name to avoid duplicate searches

About

Scraper for Magic: The Gathering card prices from LigaMagic website

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages