Skip to content

betting_combat.consumers.scrape

Polite GETs for the public pages the round dataset scrapes (Wikipedia, MMADecisions).

One request at a time, at most one every pause_s seconds (the research paced ~1.5 s); 429 and 5xx are retried with backoff, honouring Retry-After (Wikipedia has answered 429 before); 403 is asked again twice, within a budget per fetcher (below); every other HTTP error fails at once. URLs are quoted exactly as the research quoted them (unicode fighter names in MMADecisions slugs) and bodies decoded as UTF-8 with replacement, as the research decoded them.

Wikimedia refuses the cluster’s address now and then with a 403 ‘Wikimedia Error’ page while the same request from elsewhere answers 200 (2026-10-21, recovered within 40 min; 2026-10-22, five failed data updates). A refusal can pass in a minute or last an hour, so a 403 waits 30 s, then 60 s, and a fetcher spends at most FORBIDDEN_BUDGET_S waiting on 403s in all: past that a 403 fails at once and a step’s many pages cannot hang it. A long refusal is the callers’ to survive (land_card_segments reads the stored event list; an event page that cannot be read is only counted).

Classes

PacedFetcher

text

text(url: str) -> str

ScrapeError

Bases: RuntimeError

Functions

gist

gist(body: str) -> str

An error body as its text: an HTML page’s styles, scripts and tags dropped, the whitespace collapsed (a ‘Wikimedia Error’ page says why only after its stylesheet). Anything that does not start like markup is kept as it is.

quote_url

quote_url(url: str) -> str

The research’s quoting: every character outside :/?&=%#+ and the unreserved set is percent-encoded (UTF-8), existing escapes are kept.

retry_after_seconds

retry_after_seconds(value: str | None, now: dt.datetime | None = None) -> float | None

A Retry-After header as seconds to wait: delay-seconds, or an HTTP-date (the time left until it, never negative). None when absent or unreadable.