The TopDownHockey Scraper
Project description
TopDownHockey EliteProspects Scraper
By Patrick Bacon, made possible by the work of Marcus Sjölin and Harry Shomer.
This is a package built for scraping two data sources:
-
The NHL's Play-by-Play Reports, which come in the form of HTML/API reports from the NHL and JSON reports from ESPN.
-
Elite Prospects, an extremely valuable website which makes hockey data for thousands of leagues available to the public.
This package is strictly built for end users who wish to scrape data for personal use. If you are interested in using Elite Prospects data for professional purposes, I recommend you look into the Elite Prospects API.
While using the scraper, please be mindful of EliteProspects servers.
Installation
You can install the package by entering the following command in terminal:
pip install TopDownHockey_Scraper
If you're interested in using the NHL Play-By-Play scraper, import that module using this function in Python:
import TopDownHockey_Scraper.TopDownHockey_NHL_Scraper as tdhnhlscrape
If you're interested in using the Elite Prospects scraper, import that module using this function in Python:
import TopDownHockey_Scraper.TopDownHockey_EliteProspects_Scraper as tdhepscrape
User-End Functions (NHL Scraper)
scrape_full_schedule(start_date, end_date)
Returns the NHL's schedule from the API for all games for the 2023-2024 NHL season.
Example:
tdhnhlscrape.scrape_full_schedule()
full_scrape(game_id_list, shift = True)
Returns a dataframe containing play-by-play data for a list of game ids.
- game_id_list: A list of NHL game ids.
Example:
tdhnhlscrape.full_scrape([2023020179, 2023020180, 2023020181])
User-End Functions (Elite Prospects Scraper)
get_skaters(leagues, seasons)
Returns a dataframe containing statistics for all skaters in a target set of league(s) and season(s).
- leagues: One or multiple leagues. If one league, enter as a string i.e; "nhl". If multiple leagues, enter as a tuple or list i.e; ("nhl", "ahl").
- seasons: One or multiple leagues. If one league, enter as a string i.e; "2018-2019". If multiple leagues, enter as a tuple or list i.e; ("2018-2019", "2019-2020").
Example:
tdhepscrape.get_skaters(("nhl", "ahl"), ("2018-2019", "2019-2020"))
get_goalies(leagues, seasons)
Returns a dataframe containing statistics for all goalies in a target set of league(s) and season(s).
- leagues: One or multiple leagues. If one league, enter as a string i.e; "nhl". If multiple leagues, enter as a tuple or list i.e; ("nhl", "ahl").
- seasons: One or multiple leagues. If one league, enter as a string i.e; "2018-2019". If multiple leagues, enter as a tuple or list i.e; ("2018-2019", "2019-2020").
Example:
tdhepscrape.get_goalies("khl", "2015-2016")
get_player_information(dataframe)
Returns a dataframe containing bio information for all skaters or goalies (or both) within a target dataframe.
- dataframe: The dataframe returned by one of the previous two commands.
Example:
Say you obtain skater data for the KHL in 2020-2021 and store that as a dataframe called output
. You can run this function to get bio information for every player in that league's scrape.
output = tdhepscrape.get_skaters("khl", "2020-2021")
tdhepscrape.get_player_information(output)
add_player_information(dataframe)
Returns a dataframe containing bio information for all skaters or goalies (or both) within a target dataframe as well as the statistics from the original dataframe.
- dataframe: The dataframe returned by one of the previous two commands.
Example:
Say you obtain skater data for the KHL in 2020-2021 and store that as a dataframe called output
. You can run this function to get bio information for every player in that league's scrape.
output = tdhepscrape.get_skaters("khl", "2020-2021")
tdhepscrape.add_player_information(output)
Comments, Questions, and Concerns.
My goal was to make this package as error-proof as possible. I believe I've accounted for every issue that could potentially throw off a scrape, but it's possible I've missed something.
If any issues arise, or you have any questions about the package, please do not hesitate to contact me on Twitter at @TopDownHockey or email me directly at patrick.s.bacon@gmail.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file topdownhockey_scraper-4.0.0.tar.gz
.
File metadata
- Download URL: topdownhockey_scraper-4.0.0.tar.gz
- Upload date:
- Size: 37.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 441c90561008f762d77961c53aadf35ec32ba916019e5d745bb9bb0869ceeb2f |
|
MD5 | 8d325b715e82eef9b9489a76adf492c3 |
|
BLAKE2b-256 | acaa66b3b3094fae4c23ea6b5bc94ec0ff97e1203828f1fbb7eafee90f0cc916 |
File details
Details for the file TopDownHockey_Scraper-4.0.0-py3-none-any.whl
.
File metadata
- Download URL: TopDownHockey_Scraper-4.0.0-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd0d72288ae77d512f6d48a7d00fa002565ba73e483c42896cd530fc5d8880c6 |
|
MD5 | 51efa22f2c5c40bf5f8ba71f13b662d3 |
|
BLAKE2b-256 | c29f0ea423408979b560325581e0de278ca8845c6c458cf95a98b0fbfdbb5df2 |