python-cricket-scraper is built to get cricket data from Cricsheet and ESPNCricInfo
Use the package manager pip to install python-cricket-scraper.
pip3 install python-cricket-scraper
1. using single file
from cricscraper.cricsheet import CricSheet
sheet = CricSheet(files=["647261.yaml"])
sheet.save()
2. using multiple files
from cricscraper.cricsheet import CricSheet
sheets = CricSheet(files=["647261.yaml", "792295.yaml", "1122727.yaml"])
sheets.save()
3. using files in a folder
from cricscraper.cricsheet import CricSheet
sheets = CricSheet(folder="folder/")
sheets.save()
save()
method saves the CSV file, containing columns(mentioned ahead).
Notice that files parameter takes list, whereas folder takes name of folder as a string.
CricInfo class takes match id to scrape the data.
Q. Where can I get match id?
A. Google any cricket match you want. Visit Espncricinfo and get match id from url(highlighted number). 647261
in this case
from cricscraper.cricinfo import CricInfo
match = CricInfo("647261")
match.match_name()
match.match_dates()
match.playing11()
match.summary()
match.scorecard()
There are many more methods in CricInfo class. I'll encourage you to check other methods using
help(CricInfo)
from cricscraper.cricsheet import CricSheet
sheet = CricSheet(files=["647261.yaml", "792295.yaml"])
data = sheet.get_more_info()
get_more_info()
returns dictionary of CricInfo
object, match id as key
- match id - match id of the match as per ESPNCricInfo records.
- inning - Inning number.
- delivery - delivery number.
- over - Over number.
- batsman - batsman on strike.
- non striker - batsman on non-strike.
- bowler - Bowler.
- runs off bat - runs scored by batsman on particular delivery.
- extras - Extra runs of particular delivery.
- total - team total until particular delivery.
- extra kind - extra kind (byes, legbyes, widea or no ball)
- wicket kind - wicket kind (caught, bowled or lbw etc)
- player out - Player dismissed.
- fielders - Fielders involved in the wicket(caught, stumping etc).
- team1 - Playing team1.
- team2 - Playing team2.
- outcome - Match outcome type (normal - team1 or team2 won, draw - Match Drawn etc)
- winner - Match winner
- by - win by runs, wickets or innings (India won by 6 wickets, then by = wickets)
- win amount - Margin of victory (India won by 6 wickets, then win amount = 6)
- player of match - Player of match.
- toss winner - Toss winner.
- toss decision - Chosen bat or bowl.
- match type - Match format(ODI, ODM, TEST etc)
- venue - Venue.
- city - City of venue.
- gender - Male or female.
- umpire1 - Standing umpire 1
- umpire2 - Standing umpire 2
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.