Skip to main content

swehockey_scraper

This package can be used to collect data with web scraping from the page stats.swehockey.se. This is the website where the Swedish Icehockey Federation stores match statistics.

This package is only for personal usage.

I try to update this package in case something is changing. Any changes to the homepage structure means likely that functions needs to get updated as well. If you find something, please get in touch so that we can fix it.

Getting started

Package can be installed with pip
pip install swehockey_scraper

In python, import module with
import swehockey.swehockey_scraper as swe

See description of functions in package with
help(swe)

Functions can be used together and input and output is linked.

Data structure

On the page for swehockey, there are two keys available, season_id and game_id.

Season ID

For each season and league there is a schedule id. This is found in the URL, for example https://stats.swehockey.se/ScheduleAndResults/Schedule/6108 the season id is 6108.

Game ID

Each game can be found with URL of structure https://stats.swehockey.se/Game/Events/252961 Here, the game id is the last part of the URL, e.g. 252961

Functions

getGames(season_id)

Input is a list of season ids. This returns a dataframe containing all games for the specific season together with results.

cleanGames(df_games)

Input is a list of the structure as returned from getGames(). This step cleans up the data and adds additional columns for further data processing.

getTeamData(df_games_clean)

Input is a list of the structure as returned from cleanGames(). This step make a dataframe on team level. It calculate season specific metrics for each team, Head-to-Head comparisons and table positions.

getGameData(df_games_clean)

Input is a list game_ids (for example can be extracted from the output from getGames).
This function extracts game specific data like penaltys, goals, shot statistics.

Example Notebook

See this notebook for examples of how to use the package, and in what order you can run the functions.

swehockey_scraper

Package to scrape hockey data from swehockey

Release files for swehockey-scraper 1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for swehockey-scraper 1.5
File Interpreter ABI Platform
swehockey_scraper-1.5-py3-none-any.whl Python 3 none any Details

Release files / swehockey_scraper-1.5-py3-none-any.whl

Download URL swehockey_scraper-1.5-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a4f9b72b226aee9972c184070a4eb90407496ab2a8a0ccfd68dca46e6a36fc6
BLAKE2b-256 checksum
How to use checksums
efb14ded83a3559080881da7abf78de8a79753b267298059faa1e25ce0bb79f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

1.5 This release

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.0

1 release file

0.6

1 release file

0.5

3 release files

0.4

1 release file

0.3

1 release file

0.2

3 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page