Skip to main content

A simple Python package to gather live sports scores

Project description

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:

  • Baseball: sports.BASEBALL
  • Basketball: sports.BASKETBALL
  • Cricket: sports.CRICKET
  • Football: sports.FOOTBALL
  • Handball: sports.HANDBALL
  • Hockey: sports.HOCKEY
  • Rugby Union: sports.RUGBY_U
  • Rugby League: sports.RUGBY_L
  • Soccer: sports.SOCCER
  • Tennis: sports.TENNIS
  • Volleyball: 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 match
  • league: League of the match
  • home_team: Home team
  • away_team: Away team
  • home_score: Home team score
  • away_score: Away team score
  • match_time: Current match time
  • match_date: Date the match was played
  • match_link: Link to an XML file containing match data
match = sports.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_scores(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 find
  • team: Name of city or team to find (Not case-sensitive)

Properties available to all valid teams/sports:

  • name: Name of the team
  • seasons: Total number of seasons played
  • record: Overall regular season record
  • champs: Number of total championships (Includes pre-merger champs for NFL)
  • leaders: Overall team leaders for certain statistical categories
  • raw: Dictionary containing all gathered info

Properties available to only MLB teams:

  • pennants: Total number of AL/NL championships

Properties available to only NFL teams:

  • super_bowls: Total number of Super Bowls

Properties available to only NHL teams:

  • points: Total number of regular season points earned

Properties available to both NFL/NHL teams:

  • playoff_record: Overall playoff record

Properties available to MLB, NBA, NHL teams:

  • playoff_app: Total number of playoff appearances
pirates = sports.get_team_info(sports.BASEBALL, 'pirates')
print(pirates.pennants)

penguins = sports.get_team_info(sports.HOCKEY, 'penguins')
print(penguins.points)

steelers = sports.get_team_info(sports.FOOTBALL, 'steelers')
print(steelers.super_bowls)

sixers = sports.get_team_info(sports.BASKETBALL, '76ers')
print(sixers.playoff_app)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sports.py-2.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

sports.py-2.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file sports.py-2.0.0.tar.gz.

File metadata

  • Download URL: sports.py-2.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sports.py-2.0.0.tar.gz
Algorithm Hash digest
SHA256 12ec4e093cdc943d64957cebd31a853971c3e44fc0eb6505f5109601e5e6db06
MD5 7414acf6f55c7ec77cd47271d35f134e
BLAKE2b-256 4051995e49226f884ebb33613c45fd03b83c25f4ebc8a981291137c1f6a8766f

See more details on using hashes here.

Provenance

File details

Details for the file sports.py-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sports.py-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e2cb4ddfc13ded841bf56359bcee141a6396e8eb4f5e1587522a7b197ef3baf
MD5 664105d788bae13a10fff335e2a56463
BLAKE2b-256 cdc9ee32be99046d5b31757fb4d9905edd420cfcd72b3bd2076740158e135bb8

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page