Skip to main content

A simple Python package to gather live sports scores

Project description

PyPI Build Status License

sports.py

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

Installation

Requires Python 2.7 or Python >= 3.5

pip install sports.py

Usage

List of valid sports:

  • Baseball: baseball
  • Basketball: basketball
  • Cricket: cricket
  • Football: football
  • Handball: handball
  • Hockey: hockey
  • Rugby: rugby-union or rugby-league
  • Soccer: soccer
  • Tennis: tennis
  • Volleyball: volleyball

Get a single match

get_match_score() takes three parameters:

  • sport: Name of sport being played (see above for a list of valid sports)
  • team1: Name of city of a team in a match (Not case-sensitive)
  • team2: Name of city of a team in a match (Not case-sensitive)
import sports_py

match = sports_py.get_match_score('tennis', 'Murray', 'Federer')
print('{}-{}'.format(match.home_score, match.away_score))

This 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: datetime object: date the match was played
  • match_link: Link to an XML file containing match data

Get multiple matches

get_sport_scores() takes one parameter:

  • sport: Name of sport (see above for list of valid sports)
import sports_py

matches = sports_py.get_sport_scores('basketball')
for match in matches:
    print('{} vs {}: {}-{}'.format(match.home_team, match.away_team,
                                       match.home_score, match.away_score))

This returns a list of Match objects which contain the same properties described above

Get all live matches

import sports_py

all_matches = sports_py.get_all_matches()
for sport in all_matches:
    for match in sport:
            print('{} vs {}: {}-{}'.format(match.home_team, match.away_team,
                                               match.home_score, match.away_score))

Convert Match objects to JSON

import sports_py

pens_json = sports_py.get_match_score('hockey', 'panguins', 'predators').to_json()
print(pens_game)

Get extra team info

Only works with MLB, NFL, and NHL teams

Get team information including overall record, championships won and more.

get_team_info() 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 both MLB/NHL teams:

  • playoff_app: Total number of playoff appearances
import sports_py

pirates = sports_py.get_team_info('baseball', 'pirates')
print(pirates.pennants)

penguins = sports_py.get_team_info('hockey', 'penguins')
print(penguins.points)

steelers = sports_py.get_team_info('football', 'steelers')
print(steelers.super_bowls)

Credits

Evan Sloan: evansloan082@gmail.com

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sports.py-1.2.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sports.py-1.2.1.tar.gz
Algorithm Hash digest
SHA256 486f826a8e9d8216aa1099a5e29fe1d95af657d7df11e86189b51ae3e991752a
MD5 e0ef21afc2a9d643f19d809add201c6d
BLAKE2b-256 3d225afa2af88072a6031ef9b8512ac72e3109aa36794cf974c45763cecf303c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sports.py-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b443d2823aa3dd09f697342792d76fd11037357c3b502fa6d0ee57a1d6d3b80
MD5 4bd47c7d31b8ea060c19c970423d6058
BLAKE2b-256 93250d5a06c446b22b95a0ce6010387d27eaf5ce23d47be2f8cd6ab9f039c6ad

See more details on using hashes here.

Supported by

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