Library for scraping football data from WhoScored matches.
To install this library, use:
pip install whoscraped
To upgrade the library, use:
pip install --upgrade whoscraped
- Python 3.6 or higher
- Google Chrome browser
- Chromedriver installed and added to your system's PATH
The library provides the following functions:
- Get data from the match URL in JSON format:
import whoscraped
match_url = "https://www.whoscored.com/Matches/1699239/Live/International-FIFA-World-Cup-2022-Argentina-France"
match_data = whoscraped.get_match_data(match_url)
This function retrieves match data from the specified URL. The data is returned as a Python dictionary in JSON format.
- Get all passes from both teams from a match URL or match json data:
import whoscraped
match_url = "https://www.whoscored.com/Matches/1699239/Live/International-FIFA-World-Cup-2022-Argentina-France"
passes_df = whoscraped.get_match_passes(match_url)
or
import whoscraped
match_url = "https://www.whoscored.com/Matches/1699239/Live/International-FIFA-World-Cup-2022-Argentina-France"
data = whoscraped.get_match_data(url)
passes_df = whoscraped.get_match_passes(data)
This function gets all pass events from the specified match URL or json object with match data and returns a Pandas DataFrame containing the pass information.
- Get all stats from both teams from a match URL or match json data:
import whoscraped
match_url = "https://www.whoscored.com/Matches/1699239/Live/International-FIFA-World-Cup-2022-Argentina-France"
stats_df = whoscraped.get_team_stats(match_url)
or
import whoscraped
match_url = "https://www.whoscored.com/Matches/1699239/Live/International-FIFA-World-Cup-2022-Argentina-France"
data = whoscraped.get_match_data(url)
stats_df = whoscraped.get_team_stats(data)
This function gets all the home and away team stats from the specified match URL or json object with match data and returns a Pandas DataFrame containing the information.
- Get shotmap of a match from its URL or json data:
import whoscraped
match_url = "https://www.whoscored.com/Matches/1699239/Live/International-FIFA-World-Cup-2022-Argentina-France"
shots_df = whoscraped.get_shotmap(match_url)
or
import whoscraped
match_url = "https://www.whoscored.com/Matches/1699239/Live/International-FIFA-World-Cup-2022-Argentina-France"
data = whoscraped.get_match_data(url)
shots_df = whoscraped.get_shotmap(data)
This function gets all the shots from a match and returns a Pandas DataFrame containing the information.
- Get players stats of a match from its URL or json data:
import whoscraped
match_url = "https://www.whoscored.com/Matches/1699239/Live/International-FIFA-World-Cup-2022-Argentina-France"
stats_df = whoscraped.get_players_stats(match_url)
or
import whoscraped
match_url = "https://www.whoscored.com/Matches/1699239/Live/International-FIFA-World-Cup-2022-Argentina-France"
data = whoscraped.get_match_data(url)
stats_df = whoscraped.get_players_stats(data)
This function gets all the players individual stats from both teams and returns a Pandas DataFrame containing the information.
If you encounter an error, such as CantGetMatchData, ensure that the match URL is correct and that the WhoScored page has the necessary data.
If you would like to contribute to this project, please fork the repository and submit a pull request. Ensure that your code passes all tests and adheres to the project's coding standards.