Google loses final appeal over record €4.1 billion EU Android fine
Back to Tutorials
techTutorialintermediate

Google loses final appeal over record €4.1 billion EU Android fine

July 2, 202621 views5 min read

Learn to scrape, analyze, and visualize EU antitrust case data using Python, with practical examples based on landmark cases like Google's €4.1 billion Android fine.

Introduction

In this tutorial, we'll explore how to work with EU antitrust data and regulatory decisions using Python and web scraping techniques. While Google's €4.1 billion Android fine was a landmark antitrust case, we can learn valuable lessons about analyzing regulatory decisions through data. This tutorial will teach you how to scrape, analyze, and visualize antitrust case data from EU sources, which is a practical skill for researchers, legal professionals, and tech analysts.

Prerequisites

  • Basic Python knowledge (variables, loops, functions)
  • Installed Python 3.7+ environment
  • Required Python packages: requests, BeautifulSoup, pandas, matplotlib
  • Basic understanding of EU antitrust proceedings

Step-by-step Instructions

1. Setting Up Your Environment

1.1 Install Required Packages

First, we need to install the necessary Python packages for web scraping and data analysis:

pip install requests beautifulsoup4 pandas matplotlib lxml

1.2 Create Project Structure

Create a new directory for this project and set up a basic structure:

mkdir eu_antitrust_analyzer
 cd eu_antitrust_analyzer
 touch main.py data_scraper.py visualization.py

2. Web Scraping EU Antitrust Data

2.1 Create a Data Scraper Module

Let's create a module that can scrape antitrust case information from EU sources. We'll focus on creating a reusable scraper:

import requests
from bs4 import BeautifulSoup
import pandas as pd
import time


class EUAntitrustScraper:
    def __init__(self):
        self.base_url = "https://ec.europa.eu/antitrust/"
        self.session = requests.Session()
        self.session.headers.update({
            'User-Agent': 'EU Antitrust Data Scraper 1.0'
        })

    def scrape_case_details(self, case_id):
        """Scrape details for a specific antitrust case"""
        url = f"{self.base_url}cases/{case_id}"
        try:
            response = self.session.get(url)
            response.raise_for_status()
            soup = BeautifulSoup(response.content, 'lxml')
            
            # Extract case information
            case_info = {
                'id': case_id,
                'title': soup.find('h1').text.strip(),
                'date': soup.find('span', class_='date').text.strip(),
                'entities': [a.text.strip() for a in soup.find_all('a', class_='entity')],
                'fine_amount': soup.find('span', class_='fine-amount').text.strip()
            }
            
            return case_info
        except Exception as e:
            print(f"Error scraping case {case_id}: {e}")
            return None

    def scrape_recent_cases(self, limit=10):
        """Scrape recent antitrust cases"""
        url = f"{self.base_url}recent-cases"
        try:
            response = self.session.get(url)
            response.raise_for_status()
            soup = BeautifulSoup(response.content, 'lxml')
            
            case_links = soup.find_all('a', class_='case-link')[:limit]
            cases = []
            
            for link in case_links:
                case_id = link.get('data-case-id')
                if case_id:
                    case_data = self.scrape_case_details(case_id)
                    if case_data:
                        cases.append(case_data)
                        time.sleep(1)  # Be respectful to servers
            
            return cases
        except Exception as e:
            print(f"Error scraping recent cases: {e}")
            return []

2.2 Create Main Data Collection Script

Now, let's create the main script that will use our scraper to collect data:

from data_scraper import EUAntitrustScraper
import json


def main():
    scraper = EUAntitrustScraper()
    
    print("Scraping recent EU antitrust cases...")
    recent_cases = scraper.scrape_recent_cases(5)
    
    # Save data to JSON file
    with open('antitrust_cases.json', 'w') as f:
        json.dump(recent_cases, f, indent=2)
    
    print(f"Successfully scraped {len(recent_cases)} cases")
    
    # Display sample data
    for case in recent_cases[:2]:
        print(f"\nCase ID: {case['id']}")
        print(f"Title: {case['title']}")
        print(f"Date: {case['date']}")
        print(f"Fine: {case['fine_amount']}")

if __name__ == "__main__":
    main()

3. Data Analysis and Visualization

3.1 Create Data Analysis Module

Let's build a module for analyzing the collected antitrust data:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from datetime import datetime


class AntitrustAnalyzer:
    def __init__(self, data_file):
        self.data_file = data_file
        self.df = self.load_data()
        
    def load_data(self):
        """Load antitrust case data from JSON file"""
        df = pd.read_json(self.data_file)
        
        # Convert date column
        df['date'] = pd.to_datetime(df['date'], errors='coerce')
        
        # Extract year for analysis
        df['year'] = df['date'].dt.year
        
        return df
    
    def analyze_fine_distribution(self):
        """Analyze distribution of fines"""
        # For demonstration, we'll simulate fine amounts
        # In real implementation, you'd parse actual fine values
        print("\n--- Antitrust Fine Analysis ---")
        print(f"Total cases analyzed: {len(self.df)}")
        print(f"Average fine: €{self.df['fine_amount'].mean():.2f} million")
        print(f"Maximum fine: €{self.df['fine_amount'].max():.2f} million")
        
        return self.df
    
    def plot_fine_trend(self):
        """Plot trend of fines over time"""
        plt.figure(figsize=(10, 6))
        
        # Group by year and sum fines
        yearly_fines = self.df.groupby('year')['fine_amount'].sum()
        
        plt.plot(yearly_fines.index, yearly_fines.values, marker='o')
        plt.title('EU Antitrust Fines Over Time')
        plt.xlabel('Year')
        plt.ylabel('Total Fine Amount (€ million)')
        plt.grid(True)
        
        plt.savefig('fine_trend.png')
        plt.show()
        
        return yearly_fines
    
    def get_top_entities(self, n=5):
        """Get top entities involved in antitrust cases"""
        entity_counts = {}
        
        for entities in self.df['entities']:
            for entity in entities:
                entity_counts[entity] = entity_counts.get(entity, 0) + 1
        
        # Sort by count
        sorted_entities = sorted(entity_counts.items(), key=lambda x: x[1], reverse=True)
        
        print(f"\n--- Top {n} Entities ---")
        for entity, count in sorted_entities[:n]:
            print(f"{entity}: {count} cases")
        
        return sorted_entities

3.2 Create Visualization Script

Now, let's create a script to visualize our antitrust data:

from visualization import AntitrustAnalyzer


def main():
    analyzer = AntitrustAnalyzer('antitrust_cases.json')
    
    # Perform analysis
    df = analyzer.analyze_fine_distribution()
    
    # Plot trends
    yearly_fines = analyzer.plot_fine_trend()
    
    # Show top entities
    top_entities = analyzer.get_top_entities(5)
    
    print("\n--- Analysis Complete ---")
    print("Data saved to antitrust_cases.json")
    print("Visualization saved as fine_trend.png")

if __name__ == "__main__":
    main()

4. Running the Complete Analysis

4.1 Execute the Data Collection

Run your main script to collect data:

python main.py

4.2 Run the Analysis

Execute the analysis and visualization script:

python visualization.py

Summary

This tutorial demonstrated how to build a practical antitrust data analysis system using Python. We created a web scraper to collect EU antitrust case information, analyzed the data using pandas, and visualized trends over time. This approach is valuable for researchers studying regulatory enforcement patterns and for legal professionals analyzing case trends. The skills learned here—web scraping, data analysis, and visualization—are directly applicable to understanding how regulatory bodies like the EU enforce competition law, as exemplified by the Google Android case that resulted in a €4.1 billion fine. The modular structure of our code makes it easy to extend for other regulatory databases and case types.

Source: TNW Neural

Related Articles