Certainly! For your price tracking POC, Python is an excellent choice due to its rich ecosystem for web scraping, ease of use, and strong community support. We will build a simple command-line tool that:
- Takes an Amazon.nl product URL as input
- Scrapes the product name, description, and price
- Prints the results
Why Python?
- Libraries like
requests and BeautifulSoup make scraping straightforward.
- Easy to extend later with databases, schedulers, and notification systems.
- Cross-platform and widely used for automation.
Project Setup and Implementation
1. Prerequisites
- Python 3.8+
pip package manager
2. Create a project folder
mkdir amazon_price_tracker
cd amazon_price_tracker
3. Create and activate a virtual environment (optional but recommended)
python3 -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
4. Install required libraries
pip install requests beautifulsoup4 lxml
requests: for HTTP requests
beautifulsoup4: for parsing HTML
lxml: parser backend for BeautifulSoup (faster and more robust)
5. Create the main script: amazon_scraper.py
import requests
from bs4 import BeautifulSoup
HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/114.0.0.0 Safari/537.36",
"Accept-Language": "nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7"
}
def get_amazon_product_data(url: str):
try:
response = requests.get(url, headers=HEADERS)
response.raise_for_status()
except requests.RequestException as e:
print(f"Error fetching the page: {e}")
return None
soup = BeautifulSoup(response.text, 'lxml')
# Product title
title = soup.find(id="productTitle")
title_text = title.get_text(strip=True) if title else "N/A"
# Product description (try multiple selectors)
description = None
# Try product description div
desc_div = soup.find(id="productDescription")
if desc_div:
description = desc_div.get_text(strip=True)
else:
# Try feature bullets
bullets = soup.select("#feature-bullets ul li span")
if bullets:
description = "\n".join(b.get_text(strip=True) for b in bullets)
else:
description = "N/A"
# Price (try multiple selectors)
price = None
price_selectors = [
"#priceblock_ourprice",
"#priceblock_dealprice",
"#priceblock_saleprice",
".a-price .a-offscreen"
]
for selector in price_selectors:
price_tag = soup.select_one(selector)
if price_tag:
price = price_tag.get_text(strip=True)
break
if not price:
price = "N/A"
return {
"title": title_text,
"description": description,
"price": price
}
def main():
url = input("Enter Amazon.nl product URL: ").strip()
data = get_amazon_product_data(url)
if data:
print("\nProduct Information:")
print(f"Title: {data['title']}")
print(f"Description:\n{data['description']}")
print(f"Price: {data['price']}")
if __name__ == "__main__":
main()
6. Run the script
python amazon_scraper.py
Paste an Amazon.nl product URL when prompted, for example:
https://www.amazon.nl/dp/B08N5WRWNW
Notes and Next Steps
- Amazon changes its page structure often; selectors may need updates.
- For production, consider using Amazon's official API or third-party APIs to avoid scraping issues.
- Add error handling for invalid URLs or network issues.
- Extend to support multiple countries by adjusting headers and URL parsing.
- Add a database to store product info and price history.
- Implement notification (email, SMS, push) when price drops below threshold.
- Use schedulers like
cron or APScheduler for periodic checks.
If you want, I can help you extend this POC with any of the above features!