Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Sports Score updates #316

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Web-Scraping/Sports updates/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Sports Score Updates
- This script fetch the latest score for matches, team info and match info
- This script supports:
- baseball
- basketball
- cricket
- football
- handball
- hockey
- rugby-league
- rugby-union
- soccer
- tennis
- volleyball


## Setting up :
### Install requirements:
```sh
$ pip3 install sports-py
```

### Running the script:
```sh
# gets the live score:
$ python3 score_updates.py <sportName>
# gets the details of match between two teams:
$ python3 sports_score_updates.py <sportName> <team1> <team2>
# gets the details of a team:
$ python3 sports_score_updates.py <sportName> <teamName>
53 changes: 53 additions & 0 deletions Web-Scraping/Sports updates/score_updates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import sports
import sys

sdict = {
'baseball': sports.BASEBALL,
'basketball': sports.BASKETBALL,
'cricket': sports.CRICKET,
'football': sports.FOOTBALL,
'handball': sports.HANDBALL,
'hockey': sports.HOCKEY,
'rugby-league': sports.RUGBY_L,
'rugby-union': sports.RUGBY_U,
'soccer': sports.SOCCER,
'tennis': sports.TENNIS,
'volleyball': sports.VOLLEYBALL
}

arguments = sys.argv
if (len(arguments) < 2):
print('Please enter a sport as a argument we support these sports.')
for a in sdict.keys():
print(a)
exit()

if (len(arguments) == 2):
sport = arguments[1].lower()
if sport in sdict.keys():
all_matches = sports.all_matches()[sport]
for match in all_matches:
print(match)
else:
print('This sport details are not supported yet')

if (len(arguments) == 3):
sport = arguments[1].lower()
if (sport == 'baseball' or sport == 'basketball' or sport == 'football' or sport == 'hockey'):
sport = sdict.get(sport)
team = arguments[2].lower()
team_info = sports.get_team(sport, team)
print(team_info)
else:
print('This sport details are not supported yet')

if (len(arguments) == 4):
sport = arguments[1].lower()
if sport in sports_dict.keys():
sport = sports_dict.get(sport)
team1 = arguments[2].lower()
team2 = arguments[3].lower()
match_info = sports.get_match(sport, team1, team2)
print(match_info)
else:
print('This sport details are not supported yet')