A Python application designed to fetch, analyze, and manage football match data from SofaScore. It provides comprehensive capabilities for collecting, processing, and exporting data about various leagues, seasons, and matches.
For Turkish documentation, please see README.tr.md.
- Features
- System Requirements
- Installation
- Usage
- Configuration
- Data Structure
- Outputs and Data Formats
- How-to
- FAQ
- Architecture and Development
- Troubleshooting
- Contributing
- License
SofaScore Scraper offers the following key features:
-
League Management:
- List, add, and remove leagues
- View all supported SofaScore leagues
- New: Search for leagues by name
-
Season Operations:
- Fetch and list all seasons for leagues
- Automatically detect active seasons
- Manage past and future seasons
-
Match Data:
- Fetch match lists for specific leagues and seasons
- View weekly/round match data
- Collect bulk match data for all leagues
-
Detailed Match Stats:
- Fetch rich match statistics
- View team streaks and forms
- Collect pre-game form data
- Analyze Head-to-Head (H2H) statistics
-
Data Export:
- Convert match data to CSV format
- Export data by league or in bulk
- Save single match details as CSV
-
Multi-language Support:
- Turkish and English language options
- Instant language switching within the app
-
User Interface:
- Intuitive terminal-based menu system
- Colorful and categorized outputs
- Progress bars and status indicators
- Detailed error messages and logging
- Python 3.8 or higher
- pip (Python package manager)
- Internet connection (to access SofaScore API)
- 100 MB+ disk space (varies based on collected data)
Clone the project from the GitHub repository:
git clone https://github.com/tunjayoff/sofascore_scraper.git
cd sofascore_scraperAlternatively, download and extract the ZIP file.
Creating a virtual environment helps avoid package conflicts:
# Create virtual environment
python -m venv venv
# Activate virtual environment
# For Linux/MacOS:
source venv/bin/activate
# For Windows:
venv\Scripts\activateInstall the required Python packages:
pip install -r requirements.txtYou can configure environment variables using the .env file:
# Copy the example file
cp .env.example .env
# Edit the file
nano .env # or your preferred text editorRun the application using the following command in the main directory:
python main.pyTo run with specific parameters:
# Run headless (without UI)
python main.py --headless
# Update data for all leagues
python main.py --headless --update-all
# Export data to CSV
python main.py --headless --csv-exportWhen the application starts, you will see the main menu:
SofaScore Scraper v1.0.0
==========================================
Main Menu:
--------------------------------------------------
1. π League Management
2. π
Season Data
3. π
Schedule & Results
4. π Detailed Match Stats
5. π Statistics
6. βοΈ Settings
0. β Exit
Your choice (0-6):
- List Leagues: View configured leagues
- Add New League: Add a new league (Name and ID required)
- Reload League Config: Reload changes from the league file
- Search League: Search leagues by name (New!)
- Back to Main Menu: Return to the main menu
- List Seasons: View stored seasons
- Update Seasons for Single League: Fetch season data for a specific league
- Update Seasons for All Leagues: Fetch season data for all leagues
- Back to Main Menu: Return to the main menu
- List Fetched Matches: List downloaded matches
- Fetch Matches for Single League: Fetch match data for a specific league and season
- Fetch Matches for All Leagues: Fetch match data for all leagues
- Back to Main Menu: Return to the main menu
- Fetch Details for Specific Matches: Fetch detailed data for selected matches
- Fetch Details for All Matches: Fetch detailed data for all matches
- Generate CSV Dataset: Convert match data to CSV format
- Back to Main Menu: Return to the main menu
SofaScore Scraper uses two main configuration methods: environment variables and league configuration.
The project is configured via the .env file. The application automatically creates one if it doesn't exist. You can update these settings easily from the Settings menu.
Example .env file:
# API Configuration
API_BASE_URL=https://www.sofascore.com/api/v1
REQUEST_TIMEOUT=20
MAX_RETRIES=3
MAX_CONCURRENT=25
WAIT_TIME_MIN=0.4
WAIT_TIME_MAX=0.8
USE_PROXY=false
PROXY_URL=
# Data Configuration
DATA_DIR=data
FETCH_ONLY_FINISHED=true
SAVE_EMPTY_ROUNDS=false
# Display Settings
USE_COLOR=true
DATE_FORMAT=%Y-%m-%d %H:%M:%S
# Debugging
LOG_LEVEL=INFO
DEBUG=false
# Language Setting
LANGUAGE=en
You can change the following configurations from the Settings menu:
- API Configuration (URL, timeout, retries, etc.)
- Data Directory (storage location)
- Display Settings (color usage, date format)
- Language Selection (Turkish / English)
- Backup and Restore operations
You can manage leagues in the config/leagues.txt file. This determines which leagues the application tracks:
# Format: League Name: ID
Premier League: 17
LaLiga: 8
Serie A: 23
Bundesliga: 35
Ligue 1: 34
SΓΌper Lig: 52
You can add, edit, or remove leagues from the League Management menu.
SofaScore Scraper organizes collected data in the following structure:
data/
βββ seasons/
β βββ {league_id}_{league_name}_seasons.json
βββ matches/
β βββ {league_id}_{league_name}/
β βββ {season_id}_{season_name}/
β βββ round_1.json
β βββ round_2.json
β βββ ...
βββ match_details/
βββ {league_name}/
βββ season_{season_name}/
βββ {match_id}/
βββ basic.json
βββ statistics.json
βββ team_streaks.json
βββ pregame_form.json
βββ h2h.json
βββ lineups.json
- seasons.json: List of all seasons for a league
- round_X.json: Matches for a specific round/week
- basic.json: Basic match info (teams, score, date, etc.)
- statistics.json: Match statistics (shots, passes, corners, etc.)
- team_streaks.json: Team streaks/stats
- pregame_form.json: Pre-game team form
- h2h.json: Head-to-Head history
- lineups.json: Lineups and player info
CSV files are saved in data/match_details/processed/:
- Single Match CSV:
{match_id}_{timestamp}.csv - League Matches CSV:
{league_name}_{timestamp}.csv - All Matches CSV:
all_matches_{timestamp}.csv
Example CSV output:
match_id,tournament_name,season_name,round,home_team_name,away_team_name,home_score_ft,away_score_ft,match_date,home_possession,away_possession,home_shots_total,away_shots_total,home_shots_on_target,away_shots_on_target
10257123,Premier League,2023/2024,38,Manchester City,West Ham,3,1,1621789200,65,35,23,5,12,2
There are two ways to add a new league:
Select "League Management" from the main menu and use the "Add New League" option.
- Open
config/leagues.txtin a text editor. - Add the new league in the format:
League Name: ID
Premier League: 17
LaLiga: 8
To fetch all matches for a specific league and season:
- Select "Schedule & Results" (3) from the main menu.
- Select "Fetch Matches for Single League" (2).
- Select the target league from the list.
- Choose "Specific Season" (3) from the filter options.
- Select the desired season from the list.
To convert match data to CSV format:
- Select "Detailed Match Stats" (4) from the main menu.
- Select "Generate CSV Dataset" (3).
- Choose one of the conversion options:
- Single Match CSV
- League CSV
- All Leagues CSV
You can find the ID in the URL on the SofaScore website. For example, for Premier League, the URL is https://www.sofascore.com/tournament/football/england/premier-league/17. The last number (17) is the League ID.
You can find Match IDs by:
- Using the "List Fetched Matches" option in the app
- Checking the fetched JSON files
If you make too many requests, you might hit rate limits. Try:
- Lowering
MAX_CONCURRENTin.env(e.g., to 10) - Increasing
WAIT_TIME_MINandWAIT_TIME_MAX - Fetching data in smaller batches
Yes! The application supports both English and Turkish. You can change the language from the Settings menu.
The project uses a modular architecture:
- ConfigManager: Configuration and env variable management
- SeasonFetcher: Fetching and managing seasons
- MatchFetcher: Fetching match lists
- MatchDataFetcher: Fetching detailed match stats
- UI Modules: Separate handlers for different menu sections
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Developer: Tuncay EΕsiz
Version: 1.1.0
Last Updated: 26 December 2025