A simple Python package to gather live sports scores
Gather live up-to-date sports scores. Baseball, basketball, cricket, football, handball, hockey, rugby, soccer, tennis, and volleyball currently functional
Scrapes data from:
Python >= 3.5
pip install sports.py
import sports
Valid sports:
sports.BASEBALL
sports.BASKETBALL
sports.CRICKET
sports.FOOTBALL
sports.HANDBALL
sports.HOCKEY
sports.RUGBY_U
sports.RUGBY_L
sports.SOCCER
sports.TENNIS
sports.VOLLEYBALL
Get a single match
get_match()
takes three parameters:
sport
: Name of sport being played (see above for a list of valid sports)team1
: Name of city or team in a match (Not case-sensitive)team2
: Name of city or team in a match (Not case-sensitive)get_match()
returns a single Match object which contains the following properties:
sport
: Sport of the matchleague
: League of the matchhome_team
: Home teamaway_team
: Away teamhome_score
: Home team scoreaway_score
: Away team scorematch_time
: Current match timematch_date
: Date the match was playedmatch_link
: Link to an XML file containing match datamatch = sports.get_match(sports.TENNIS, 'Murray', 'Federer')
Get multiple matches
get_sport()
takes one parameter:
sport
: Name of sport (see above for list of valid sports)get_sport()
returns a list of Match objects which contain the same properties described above
matches = sports.get_sport(sports.BASKETBALL)
Get all live matches
all_matches()
returns a dictionary of Match objects grouped by sport conatining data from all live matches.
all_matches = sports.all_matches()
baseball = all_matches['baseball']
Get extra team info
Only works with MLB, NBA, NFL, and NHL teams
Get team information including overall record, championships won and more.
get_team()
takes two parameters:
sport
: Sport of the team the findteam
: Name of city or team to find (Not case-sensitive)Properties available to all valid teams/sports:
name
: Name of the teamseasons
: Total number of seasons playedrecord
: Overall regular season recordchamps
: Number of total championships (Includes pre-merger champs for NFL)leaders
: Overall team leaders for certain statistical categoriesraw
: Dictionary containing all gathered infoProperties available to only MLB teams:
pennants
: Total number of AL/NL championshipsProperties available to only NFL teams:
super_bowls
: Total number of Super BowlsProperties available to only NHL teams:
points
: Total number of regular season points earnedProperties available to both NFL/NHL teams:
playoff_record
: Overall playoff recordProperties available to MLB, NBA, NHL teams:
playoff_app
: Total number of playoff appearancespirates = sports.get_team(sports.BASEBALL, 'pirates')
print(pirates.pennants)
penguins = sports.get_team(sports.HOCKEY, 'penguins')
print(penguins.points)
steelers = sports.get_team(sports.FOOTBALL, 'steelers')
print(steelers.super_bowls)
sixers = sports.get_team(sports.BASKETBALL, '76ers')
print(sixers.playoff_app)