Matches¶
- class Match(match_id, series_id=None)[source]¶
One match, loaded from its ESPNcricinfo full-scorecard page.
Loading starts a headless WebKit browser, because the site’s CDN refuses plain HTTP clients. Example values below are for
Match(1478914, 1478874).- innings: list[dict[str, Any]]¶
team id, runs, wickets, overs,
fours,sixes(None where ESPN has no figures) and ESPN’s raw lists.- Type:
One dict per innings
- all_innings: list[dict[str, Any]]¶
ESPN’s raw innings records, including partnerships and commentary.
- match_winner: str | None¶
Abbreviation of the winner; None for no result, a tie or an unplayed match.
- property batting_scorecard: list[list[BattingEntry]]¶
one list per innings, one row per batter.
Outer list is indexed by innings order; inner list has one entry per batsman. Players who did not bat have
batted=Falseand numeric fields asNone.Example:
for i, innings in enumerate(m.batting_scorecard, 1): print(f"Innings {i}:") for b in innings: print(b["name"], b["runs"], b["balls"], b["dismissal"])
- Type:
Batting scorecard
- property bowling_scorecard: list[list[BowlingEntry]]¶
one list per innings, one row per bowler.
Outer list is indexed by innings order; inner list has one entry per bowler.
Example:
for i, innings in enumerate(m.bowling_scorecard, 1): print(f"Innings {i}:") for b in innings: print(b["name"], b["wickets"], b["runs"], b["overs"])
- Type:
Bowling scorecard
- property over_by_over: list[list[OverEntry]]¶
one list per innings, one row per over.
Empty for an innings ESPN has no over data for, as with early Tests.
Example:
for over in m.over_by_over[0]: print(over["over"], over["runs"], over["total_runs"])
- Type:
Runs and wickets per over
- static get_recent_matches(date=None)[source]¶
Return MatchRefs for the matches on ESPNcricinfo’s results page.
ESPN returns roughly the two weeks of matches ending on
date. Useget_matches_on()for the matches played on one day.
- static get_matches_on(date=None)[source]¶
Return MatchRefs for the matches being played on one day.
A match counts if the day falls between its start and end dates, so a Test appears on each of its days.
- class MatchRef(series_id, match_id)[source]¶
A lightweight reference to an ESPN Cricinfo match.
Stores the
series_idandmatch_idneeded to construct aMatch. Supports dict and CSV serialization and tuple unpacking for backward compatibility.Example:
from espncricinfo.match_ref import MatchRef ref = MatchRef(series_id=1478874, match_id=1478914) series_id, match_id = ref # tuple unpacking still works m = ref.to_match() # hydrate a full Match object d = ref.to_dict() # {"series_id": 1478874, "match_id": 1478914} row = ref.to_csv_row() # ["1478874", "1478914"]
- class Summary(date=None)[source]¶
Recent matches as
MatchRefobjects.Uses Match.get_recent_matches() which scrapes the ESPN Cricinfo results page via Playwright. Pass an optional date string (YYYY-MM-DD or DD-MM-YYYY) to get matches for a specific day; defaults to today.
Example:
from espncricinfo.summary import Summary for ref in Summary().matches: m = ref.to_match() print(m.description) # Tuple unpacking also works: for series_id, match_id in Summary().matches: print(series_id, match_id)
Row types¶
Scorecard rows and teams are plain dicts at runtime; these TypedDicts give
their keys and value types.
- class BattingEntry[source]¶
One row of
Match.batting_scorecard.Numeric fields are
Nonefor players who did not bat.
- class OverEntry[source]¶
One over of
Match.over_by_over.
- class BowlingEntry[source]¶
One row of
Match.bowling_scorecard.