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.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 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.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distributions

sports.py-2.0.2-py3.7.egg (13.8 kB view details)

Uploaded Source

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sports.py-2.0.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.2

File hashes

Hashes for sports.py-2.0.2.tar.gz
Algorithm Hash digest
SHA256 e879f9cbfa7a7e11b987750724265a1abff3995d5b8b0337b5e526ff74b84089
MD5 4e305e9aa065266949165401f62d916a
BLAKE2b-256 805a4cf9a97436787e58f3069f9831caa2be9551e485759375d41f45fedab73a

See more details on using hashes here.

Provenance

File details

Details for the file sports.py-2.0.2-py3.7.egg.

File metadata

  • Download URL: sports.py-2.0.2-py3.7.egg
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.2

File hashes

Hashes for sports.py-2.0.2-py3.7.egg
Algorithm Hash digest
SHA256 5e561285a1c9f8a8625a58d2d2edacddec7737b3fb52337de8790393142f6f13
MD5 f05ae377c4f92c6a3f5150f0bb817ccb
BLAKE2b-256 9629bbbfd49d3c38290dd3d3612140c6bb134b67fcae8c8de12b8d55da7fea69

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: sports.py-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.2

File hashes

Hashes for sports.py-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f72780c7b3d6d5c5547da90116b6a88fdb5a6ab40ab09fbefa6246a2af40cbbb
MD5 7425464358ff77ac81b096e71061faac
BLAKE2b-256 772b97857dce99dfd5b4a1cf0eefd3574b62129c2e2e1d19dd6181903fc9dc15

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