This project demonstrates web scraping, data cleaning, currency conversion, and data storage using Python. It involves scraping product data from:
-
Books to Scrape (static website)
-
Jumia Kenya (dynamic e-commerce website)
The project uses requests, BeautifulSoup, pandas, and tabulate, with real-time currency conversion APIs and robust error handling.
-
Scrape at least 10–15 products
-
Extract product name and price
-
Clean and structure raw data
-
Convert prices using a free currency API
-
Save output to CSV and JSON
-
Display results in readable tabular format
-
Handle network and scraping errors gracefully
-
Python 3
-
requests
-
beautifulsoup4
-
pandas
-
tabulate
-
re (regular expressions)
-
Currency API: open.er-api.com
web-scraping-project/ │ ├── books_scraper.py ├── jumia_scraper.py ├── books.csv ├── books.json ├── jumia.csv ├── jumia.json ├── requirements.txt └── README.md
1️⃣ Create a Virtual Environment
python -m venv venv
2️⃣ Activate the Environment
Windows
venv\Scripts\activate
macOS / Linux
source venv/bin/activate
3️⃣ Install Dependencies
pip install requests beautifulsoup4 pandas tabulate
(Optional)
pip freeze > requirements.txt
🔗 Website
-
Book title
-
Price in GBP (£)
-GBP → KES using:
https://open.er-api.com/v6/latest/GBP
-
books.csv
-
books.json
-
Static HTML
-
Scraping-friendly
-
Ideal for learning and exams
-
Product name
-
Price in KES
- KES → USD (or any supported currency)
API used:
https://open.er-api.com/v6/latest/KES
Jumia uses basic bot protection, therefore:
Custom User-Agent headers are used
Scraping is done via search/category pages
Results may vary depending on request frequency
This behavior is normal and expected in real-world scraping.
✔ Data scraping with BeautifulSoup ✔ Data cleaning using regex ✔ Currency conversion using live API ✔ CSV and JSON storage ✔ Table display with pandas/tabulate ✔ Network and runtime error handling
+---------------------------+-------------+------------+ | Product / Title | Price_KES | Price_USD | +---------------------------+-------------+------------+ | Samsung Galaxy A14 | 14999 | 115.83 | | Infinix Smart 7 | 10999 | 84.95 | +---------------------------+-------------+------------+
The scripts handle:
-
Network timeouts
-
API failures
-
Missing HTML elements
-
Empty results
Example:
except requests.exceptions.RequestException as e: print("Network error:", e)
-
Practical web scraping
-
Real-world data cleaning
-
API consumption
-
Structured data storage
-
Understanding scraping limitations on e-commerce platforms
-
Multi-page scraping
-
Proxy rotation
-
Retry/backoff logic
-
Database storage (SQLite/PostgreSQL)
-
Scheduler (cron / task scheduler)
- Emmanuel Lihanda
- +254 796285410
- Pharmacy & Technology Enthusiast