Skip to content

Scrape Booking.com Hotel Data with Python

Booking.com search pages combine JavaScript-rendered listings with strict anti-bot controls, so a plain HTTP request often returns an incomplete page or a block. For this Python workflow, choose a scraping service that supports headless-browser rendering, residential proxy routing and CSS extraction rules. The documented client requests those capabilities and turns each property card into structured fields; verify the selected service supports the options before running it.

Set up the environment and client

Install Python 3.6 or newer, then install the SDK package and pandas with pip. Obtain an API key from the scraping service you intend to use, and create a Python file for the script. Import the SDK client and pandas. Initialise the client with the key and set a search URL for the destination, dates, guests and rooms you want — the historical illustration uses a Rome search for 25-26 October 2025 with two adults; TARGET_URL supplies the search URL used by the executable example.

Render the page and make the request

Define a function to hold the scraping logic. Inside it, add a JavaScript scenario that waits 3000 milliseconds so listing cards and prices load before extraction. Then send a GET request through the client, passing the scenario and enabling premium proxy routing. The complete example below checks for status 200, reads the structured response, writes the CSV, then prints the status and table. Its final non-indented line calls the function. If content is missing, extend the JavaScript scenario with extra interaction steps.

Extract hotel fields with CSS selectors

Inspect the live page with browser developer tools to find selectors. The container selector targets each property card; nested selectors pick out the hotel name, price, review score and address. Assemble these into an extract_rules dictionary with type set to list so every card on the page is returned. Switch the result handling from raw text to JSON and run the script again to verify clean structured output.

Export results to CSV

Convert the extracted list into a pandas DataFrame and write it to a CSV file in the project folder. That file can then be opened in a spreadsheet for comparison or further analysis. To target a different trip, replace the URL with one carrying your destination, check-in and check-out dates, and adjust selectors if the page layout changes.

Install the documented client and pandas. Set API_KEY to a key valid for the service endpoint used by that client, and set TARGET_URL to a Booking search URL. Run the example from your project directory so Booking_scraper.csv is written there. Check that the selectors match your chosen page; access still depends on the target and service configuration. The Search_Result list supplies the CSV rows.

import os
import pandas as pd
from scrapingbee import ScrapingBeeClient

def scrape_Booking():
    service = ScrapingBeeClient(api_key=os.environ["API_KEY"])
    options = {'js_scenario': {'instructions': [{'wait': 3000}]},
     'extract_rules': {'Search_Result': {'selector': "div[data-testid='property-card-container']",
                                         'type': 'list',
                                         'output': {'Name': "div[data-testid='title']",
                                                    'Price': "span[data-testid='price-and-discounted-price']",
                                                    'Score': "div[data-testid='review-score'] "
                                                             '> '
                                                             "div[aria-hidden='true']",
                                                    'Location': "span[data-testid='address']"}}},
     'premium_proxy': 'True'}
    response = service.get(os.environ["TARGET_URL"], params=options)
    if response.status_code != 200:
        raise RuntimeError("HTTP status " + str(response.status_code))
    hotels = response.json()["Search_Result"]
    frame = pd.DataFrame(hotels)
    frame.to_csv("Booking_scraper.csv", index=False)
    print(response.status_code)
    print(frame)

scrape_Booking()

Pre-run checklist

Use this checklist before a larger run: confirm Python version and installed packages; confirm the API key is set; confirm the URL encodes the right destination and dates; confirm the wait time is long enough for cards to render; test selectors in developer tools first; check the HTTP status code; and confirm the CSV opens with the expected columns — name, price, score and location.

Frequently asked questions

Can I scrape Booking.com with Python?

Yes. Use a Python SDK with a service that supports the proxy routing and JavaScript rendering your target needs. The example requests structured hotel names, prices and ratings in one API request; successful access still depends on the target and service configuration.

Why does Booking.com block my scraper?

Strict bot detection, IP bans, CAPTCHA challenges and JavaScript-loaded content are the usual obstacles. Residential connections and browser emulation are the countermeasures described here.

Can I get prices, reviews and location info?

Yes. With suitable CSS selectors inside extract rules, prices, guest scores and address details can be pulled into structured JSON or CSV output.

How do I handle JavaScript and dynamic content?

Enable JavaScript rendering so requests run in a headless browser and page elements finish loading before extraction begins.