Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

World Cup Data Scraping with Python and Zenrows

A complete football analytics pipeline that scrapes World Cup data from multiple public sources, normalizes it into reusable datasets, and generates publication-ready visualizations.

Features

  • Scrapes official FIFA tournament statistics
  • Scrapes advanced player statistics from SofaScore
  • Extracts tournament metadata from Wikipedia
  • Normalizes data into reusable JSON datasets
  • Exports normalized CSV files for further analysis
  • Generates interactive Plotly visualizations
  • Generates publication-ready Matplotlib charts
  • Organizes outputs into a reproducible analytics pipeline

Prerequisites

  • Python
  • Zenrows API key

Installation

1. Clone the repository

git clone https://github.com/ZenRows/scraping-world-cup-data.git

cd scraping-world-cup-data

2. Create a virtual environment

python -m venv .venv

3. Activate the virtual environment

macOS / Linux:

source .venv/bin/activate

Windows:

.venv\Scripts\activate

4. Install dependencies

pip install -r requirements.txt

Configuration

This project uses Zenrows Fetch and Browser Sessions to access data from multiple protected web sources.

Create a .env file in the project root.

ZENROWS_API_KEY=your_api_key

Replace your_api_key with your Zenrows API key.

Project structure

.
├── charts/
│   ├── fifa/
│   ├── sofascore/
│   └── wikipedia/
│
├── data/
│   ├── raw/
│   │   ├── fifa/
│   │   ├── sofascore/
│   │   └── wikipedia/
│   │
│   └── normalized/
│       ├── fifa/
│       ├── sofascore/
│       └── wikipedia/
│
├── data_sources/
├── normalizers/
├── visualizers/
│   ├── fifa/
│   ├── sofascore/
│   └── wikipedia/
│
├── main.py
├── requirements.txt
└── README.md

How it works

The pipeline collects World Cup data from FIFA, SofaScore, and Wikipedia before normalizing the datasets and generating visualizations.

                   FIFA
                  │
          SofaScore
                  │
          Wikipedia
                  │
                  ▼
          Data collection
                  │
                  ▼
          Data normalization
                  │
                  ▼
       Visualization pipeline
                  │
                  ▼
     PNG • HTML • CSV outputs

The pipeline performs three stages:

  1. Scrape raw data
  2. Normalize the datasets
  3. Generate visualizations

Running the project

Execute the complete pipeline:

python main.py

Output

Running the project generates three categories of output.

Raw data

data/raw/

Contains the original HTML and JSON responses collected from the sources.

Normalized data

data/normalized/

Contains cleaned datasets ready for analysis.

Example:

data/normalized/fifa/

attacking.json
defending.json
discipline.json
distribution.json
goalkeeping.json
movement.json
physical.json

Visualizations

Generated visualizations are saved to:

charts/

Each visualization is exported as:

  • PNG
  • Interactive HTML
  • CSV (where applicable)

FIFA

  • Possession vs Goal Attempts
  • Passing Accuracy vs Defensive Line Break Attempts
  • Goalkeeper Saves vs Goals Conceded
  • Goalkeeper Save Percentage vs Expected Goals
  • Defensive Pressure vs Ball Recovery Time
  • Shot Location vs Conversion Rate
  • Speed Runs vs Off-Ball Passing Options
  • Runs in Behind vs Receptions in Behind

SofaScore

  • xG vs Goals
  • Big Chances Missed vs Conversion
  • Passing Accuracy vs Key Passes
  • Big Chances Created vs Assists
  • Goalkeeper Metrics
  • Player Rating Distribution
  • Top Defenders

Wikipedia

  • Hosts vs Stadiums

Technologies

  • Python
  • Playwright
  • Zenrows Fetch
  • Zenrows Browser Sessions
  • BeautifulSoup
  • Pandas
  • NumPy
  • Plotly
  • Matplotlib

Data sources

Source Data Collected
FIFA Team attacking, defending, passing, physical, movement, discipline, and goalkeeping statistics
SofaScore Player attacking, passing, defending, and goalkeeping statistics
Wikipedia Tournament hosts, cities, and stadium information

Notes

  • The pipeline is modular. Each data source client, normalizer, and visualizer can be run independently.
  • Charts are generated in both static and interactive formats.
  • The normalized datasets are designed to be reusable for downstream analytics workflows.

Related article

This repository accompanies this blog: Scraping 2026 FIFA World Cup Data With Python and Zenrows