Scrape Google Hotels with Python: Names, Prices, Ratings
Google Hotels aggregates live pricing, availability, ratings, and reviews from multiple booking platforms, which makes it a useful source for competitive pricing and market research. The catch is that the page is JavaScript-heavy and protected by anti-bot measures, so a plain HTTP request usually returns little of value. This guide walks through a managed-API approach: install the client, send one request with extraction rules, and save the structured result to CSV. The code modules below are the exact contracts for the workflow; the prose explains how to use them and what to check when something goes wrong.
What you get and when this approach fits
The workflow extracts three fields per hotel card: name, price, and rating. That is enough for price monitoring, competitor benchmarking, and seasonal trend analysis. It is not a full property database: amenities, location, and review text require additional selectors that you define yourself.
Use a managed scraping API when you want proxy rotation, JavaScript rendering, and anti-bot handling without maintaining browser infrastructure. Build your own headless browser stack when you need full control over request pacing, fingerprinting, and selector maintenance, and you are prepared to absorb the operational cost.
Decision checklist:
- You need results this week and have basic Python skills: managed API.
- You need to scrape thousands of city/date combinations on a schedule: managed API with caching and pagination.
- You need custom browser behavior or on-premise data handling: self-built headless browser.
- You need only a one-off snapshot: either works; the managed API is faster to set up.
Set up the Python environment
Create an isolated environment so the client and its dependencies do not collide with other projects. The virtual-environment commands are provided as an exact module; run them from your project folder. Then install the Python client with the package command in its own module. After installation, create a source file such as google_hotels_scraper.py and keep your API key out of version control.
The account signup and dashboard key retrieval are owner-side steps. Treat the key as a secret: load it from an environment variable rather than pasting it into shared code.
Send the first request and map the fields
The request targets a Google travel search URL for hotels in a city. Two parameters do the heavy lifting: country_code sets the regional result context, and extract_rules defines a list selector plus an output map. In the supplied example the list selector is div.PVOOXe, the name comes from h2, the price from div.YQIgUd, and the rating from span.KFi5wf.
Field map:
- Output key hotels: the list of matched hotel cards.
- name: text of the h2 inside each card.
- price: text of the price element; strip the currency symbol before numeric conversion.
- rating: text of the rating element.
These selectors are tied to Google's current markup. If the page structure changes, the request can still return HTTP 200 while the hotels list is empty. That is a selector failure, not a network failure. Check the raw response body before assuming the API is down.
Parse and save the results
Once the response is a 200, load the JSON and build a DataFrame from the hotels list. The price field arrives as text with a currency symbol, so remove the symbol and cast to a numeric type before analysis. Write the frame to CSV for spreadsheet work; keep the raw JSON if you need the original nesting.
Failure distinction:
- Non-200 status: request-level problem (auth, quota, upstream block). Inspect the status and body.
- 200 with empty hotels: extraction-level problem. The selector no longer matches, or the page variant differs by region.
- 200 with partial fields: one selector matches but another does not. Validate each output key separately.
For more complex patterns, the data-extraction documentation covers nested structures and conditional extraction.
Why teams scrape hotel search results
Hotel search results combine real-time prices from multiple booking platforms with ratings, reviews, and date-specific availability. That mix supports several concrete tasks:
- Price monitoring across booking platforms.
- Market analysis of availability and pricing in a location.
- Competitive intelligence on promotions and rate changes.
- Travel research on amenities and options.
- Dynamic pricing models trained on observed trends.
- Seasonal demand analysis for campaign planning.
- Predictive models for revenue management.
A hotel chain can check whether its properties are priced competitively across platforms. A travel agency can compare options for clients. A research team can study how prices move across seasons. The same extracted fields serve all three, but the refresh cadence and date ranges differ.
Best practices that keep the pipeline healthy
Minimize requests: use specific locations and date ranges instead of broad queries, and cache results that change infrequently. Add retry logic with exponential backoff for transient network or service errors. Handle pagination so you collect every page you need rather than only the first screen.
Keep proxy rotation enabled. Google blocks IPs that issue too many requests in a short window, and rotation spreads requests across addresses. Keep JavaScript rendering on for hotel pages, because prices and availability load dynamically. When you scrape simpler pages, disable rendering to save credits, and use block_resources to skip images, media, fonts, and stylesheets. Use extract_rules to return only the fields you need.
Credit awareness: rendering consumes more credits than plain requests, so budget for it on hotel pages and avoid it elsewhere. The exact parameter modules below show the supported inputs.
Putting the data to work
Once extraction is stable, the value comes from what you do with the rows. Compare a property's rate against the same dates on competing platforms, flag gaps beyond a threshold, and route those flags to a pricing owner. Track rating changes alongside price changes to see whether a rate increase coincides with sentiment decline. Keep a dated snapshot of each run so trend analysis has a consistent baseline.
Start with one city and a narrow date range, confirm the three fields populate, then expand coverage. Review selectors on a schedule, because markup changes are the most common cause of silent empty results.
Frequently asked questions
Is scraping Google Hotels legal?
Scraping is generally treated as permissible for personal or research use, but you should review Google's Terms of Service and robots.txt. Commercial use depends on jurisdiction and contract terms, so consult a legal professional before building a commercial product on the data.
Can a managed API handle JavaScript-heavy hotel pages?
Yes. The client renders pages in real Chrome browsers, so dynamic content such as prices and availability loads before the HTML is returned. Set render_js to True in the request parameters to enable it.
How do I extract hotel ratings and prices?
Use extraction rules with CSS selectors that target the rating and price elements. In the supplied example, ratings sit in elements with class KFi5wf and prices in YQIgUd. Map each selector to an output key so the response arrives as structured JSON.
What does it cost to scrape Google Hotels?
Cost depends on the plan and on how many credits each request consumes. JavaScript rendering uses more credits than a plain request, so hotel pages cost more per call than static pages. Check the current pricing page for plan details and credit rates before committing to a monitoring schedule.