evansloan / sports.py

A simple Python package to gather live sports scores
MIT License
60 stars 17 forks source link
baseball basketball football handball hockey python soccer sports sports-stats volleyball

PyPI PyPI - Python Version

Build Status Coveralls github branch License

sports.py

Gather live up-to-date sports scores. Baseball, basketball, cricket, football, handball, hockey, rugby, soccer, tennis, and volleyball currently functional

Scrapes data from:

Installation

Python >= 3.5

pip install sports.py

Usage

import sports

Valid sports:

Get a single match

get_match() takes three parameters:

get_match() returns a single Match object which contains the following properties:

match = sports.get_match(sports.TENNIS, 'Murray', 'Federer')

Get multiple matches

get_sport() takes one parameter:

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:

Properties available to all valid teams/sports:

Properties available to only MLB teams:

Properties available to only NFL teams:

Properties available to only NHL teams:

Properties available to both NFL/NHL teams:

Properties available to MLB, NBA, NHL teams:

pirates = 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)