Hotel pricing analysis across North Africa using Python web scraping and data cleaning
# π¨ North African Hotel Pricing & Satisfaction Monitor
A web scraping and business intelligence project that collects, cleans, and analyses hotel data from Booking.com across five North African countries β building Power BI dashboards to surface pricing patterns and guest satisfaction insights.
---
## π Project Overview
| | |
|---|---|
| **Data source** | Booking.com (Selenium scraper) |
| **Countries covered** | Tunisia, Morocco, Algeria, Libya, Mauritania |
| **Cities** | Tunis, Marrakech, Algiers, Tripoli, Nouakchott |
| **Seasons scraped** | Spring (May), Summer (July), Low Season (September) |
| **Hotels in dataset** | 806 |
| **Total guest reviews** | ~540,000 |
| **Visualisation tool** | Microsoft Power BI |
---
## ποΈ Project Structure
```
βββ booking_scraper.py # Selenium scraper β collects raw hotel data from Booking.com
βββ clean_hotels2.py # Data cleaning script β standardises and prepares the dataset
βββ north_africa_hotels.csv # Output dataset (generated after running the scraper)
βββ dashboards/ # Power BI (.pbix) file with all four dashboards
```
---
## βοΈ How It Works
### 1. Scraping (`booking_scraper.py`)
Uses **Selenium** and **ChromeDriver** to navigate Booking.com search result pages programmatically.
For each country/city and season combination, the scraper:
- Builds a Booking.com search URL with the correct check-in/check-out dates
- Scrolls the page to trigger lazy-loaded hotel cards
- Extracts from each card: hotel name, price, review score, review label, review count, and address/distance
- Retries up to 3 times on connection failure and saves progress incrementally to `north_africa_hotels.csv`
**Output columns:**
| Column | Description |
|---|---|
| `country` | Country name |
| `city` | City scraped |
| `season` | Season label (May_Spring, July_Summer, September_LowSeason) |
| `checkin` / `checkout` | Dates used for the search |
| `name` | Hotel name |
| `price` | Nightly rate as displayed on Bookin β¦