Skip to content

Repository files navigation

Hotel Price Scraper

A Python project for scraping hotel prices from Booking.com. This scraper can extract price information, hotel details, and booking dates from Booking.com hotel pages.

Features

  • 🏨 Extract hotel name, address, and rating
  • 💰 Get current pricing information
  • 📅 Extract check-in/check-out dates
  • 🌙 Number of nights calculation
  • 🤖 Handles anti-bot measures with Selenium
  • 📝 Comprehensive logging
  • 🛡️ Error handling and retry logic

AWS Architecture

This project is designed to run on AWS infrastructure with the following components:

Architecture Diagram

image

Architecture Overview:

  • VPC (10.0.0.0/16) with public and private subnets in Availability Zone A
  • Public Subnet (10.0.1.0/24) contains the EC2 instance with public IP
  • Amazon EC2 instance running the hotel scraper application
  • Amazon IAM role for EC2 instance with inline policies to connect to dynamodb and S3. SSM and CloudWatch included.
  • Amazon Dynamodb table Table where records about hotel is saved
  • Amazon S3 bucket for screenshot storage
  • Amazon CloudWatch for collecting logs from EC2 instance under /var/log/hotel_scraper.log
  • Sessions Manager for secure access to EC2 instance
  • Internet Gateway for external connectivity to Booking.com and other services

Installation

Setup

  1. Create a virtual environment:
python3 -m venv venv
  1. Activate the virtual environment:
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt

Activating the Environment

Before running the scraper, always activate the virtual environment:

source venv/bin/activate

When you're done, deactivate it:

deactivate

Usage

Run the Example

The project includes an example that scrapes the Goodview Serviced Apartment in New Zealand:

python example_usage.py

Multi-Country Price Comparison

Running it with NordVPN, you can compare hotel prices across different countries:

./ec2_quick_setup.sh
source venv/bin/activate
./multi_country_hotel_scraper_ec2.py

Requirements for Multi-Country Scraping:

  • NordVPN subscription and CLI installed
  • Must be logged into NordVPN (nordvpn login)
  • Stable internet connection

This will:

  • Connect to multiple countries via NordVPN
  • Scrape the same hotel from each location
  • Compare pricing differences by region
  • Generate CSV and JSON reports
  • Take screenshots for verification

Sample Output

{
  "hotel_name": "Goodview Serviced Apartment",
  "address": "Auckland, New Zealand",
  "rating": "8.5",
  "raw_price": "NZ$2,356",
  "cleaned_price": 2356.0,
  "checkin_date": "Sat 8 Mar 2026",
  "checkout_date": "Sun 22 Mar 2026",
  "nights": "14 nights",
  "scraped_at": "2024-10-27T19:30:00.000000",
  "url": "https://www.booking.com/hotel/..."
}

Requirements

  • Python 3.7+
  • Chrome browser (for Selenium WebDriver)
  • Internet connection

Notes

  • The scraper uses Selenium with Chrome WebDriver for better compatibility with dynamic content
  • Includes anti-detection measures to avoid being blocked
  • Respects website's robots.txt and rate limiting
  • For educational and personal use only

Disclaimer

This tool is for educational purposes only. Please respect Booking.com's terms of service and use responsibly. Consider using official APIs when available for production use.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages