How to scrape TripAdvisor for Hotel Data, Pricing and Reviews using Python has tons of information regarding hotels from all over the world, which can be used for monitoring prices of hotels in a locality, competitive pricing, analyzing how the price changes with each season, understand ratings of hotels in a city and lot more. We are dividing the tutorial into two parts to scrape Tripadvisor

  1. Scrape Hotel List for City
  2. Scrape Hotels Details from a Hotel URL

In this part of the tutorial to scrape Tripadvisor, we’ll search for hotels in a City, for specific check-in and check-out dates and extract the following data from the first page of search results

  1. Hotel Name
  2. Hotel Detail Page URL
  3. Number of Reviews
  4. Tripadvisor Rating
  5. Hotel Features
  6. Booking Provider
  7. Price per Night
  8. Number of Deals available

The annotated screenshot below shows the data extracted using Tripadvisor scraper.


Scraping Logic

  1. Construct the search results page URL from TripAdvisor – Tripadvisor has complex URL for the search results page of each locality. For example here is the one for Boston We’ll have to construct this URL manually to scrape results from that page. We do that by getting this URL from Tripadvisor autocomplete API.
  2. Download HTML of the search result page using Python Requests – Quite easy, once you have the URL. We use python requests to download the entire HTML of this page.
  3. Parse the page using LXML – LXML lets you navigate the HTML Tree Structure using Xpaths. We have predefined the XPaths for the details we need in the code.
  4. Save the data to a CSV file


Since this is web scraping tutorial using Python, you’ll obviously need Python. We use some python packages for downloading and parsing the HTML. Below are the requirements

  • Python 2.7 ( )
  • PIP to install the  following packages in Python (
  • Python Requests, to make requests and download the HTML content of the pages (
  • Python LXML, for parsing the HTML Tree Structure using Xpaths ( Learn how to install that here – )

The Code

The code is self-explanatory. We’ve added positional arguments in the command line scripts to specify check-in check-out date, locality and sort order for the results.

You can download the Tripadvisor code from here if the embed above doesn’t work.

Running the Scraper

Assuming you named the script If you type in the script name in a command prompt or terminal with an -h

python -h

usage: [-h] checkin_date checkout_date sort locality

positional arguments:
  checkin_date   Hotel Check In Date (Format: YYYY/MM/DD
  checkout_date  Hotel Chek Out Date (Format: YYYY/MM/DD)
  sort           available sort orders are : priceLow - hotels with lowest
                 price, distLow : Hotels located near to the search center,
                 recommended: highest rated hotels based on traveler reviews,
                 popularity :Most popular hotels as chosen by Tipadvisor users
  locality       Search Locality

optional arguments:
  -h, --help     show this help message and exit

Run it using python with arguments for the locality, sort order, check-in and check-out dates in  YYYY/MM/DD format.

For an example – finding hotels in Boston for 2017-Jan-01 to 2017-Jan-02, sorted by popularity.

 python "2017/01/01" "2017/01/02" "popularity" "boston"

This will create a CSV file called tripadvisor_data.csv  in the same folder as the script.

Here is some sample data extracted from TripAdvisor for the command above.


You can download the code at

Let us know in comments how this scraper worked for you.

Part 2 can be found here How to scrape Hotel Details using Python and LXML

Known Limitations

This code should work for grabbing the first page of results for most cities. However, if you want to scrape for thousands of pages there are some important things you should be aware of and you can read about them at Scalable do-it-yourself scraping – How to build and run scrapers on a large scale and How to prevent getting blacklisted while scraping .

If you need some professional help with scraping complex websites like TripAdvisor let us know by filling up the form below.

Tell us about your complex web scraping projects

Turn the Internet into meaningful, structured and usable data

Please DO NOT contact us for any help with our Tutorials and Code using this form or by calling us, instead please add a comment to the bottom of the tutorial page for help

Disclaimer: Any code provided in our tutorials is for illustration and learning purposes only. We are not responsible for how it is used and assume no liability for any detrimental usage of the source code. The mere presence of this code on our site does not imply that we encourage scraping or scrape the websites referenced in the code and accompanying tutorial. The tutorials only help illustrate the technique of programming web scrapers for popular internet websites. We are not obligated to provide any support for the code, however, if you add your questions in the comments section, we may periodically address them.


stedentriplonden January 4, 2017

Thanks for helping me getting used with Python, this script is working well! The only problem i get is prices are printed incorrect and i can’t seem to solve the problem:






I’m in Tripadvisor europe so i’m getting Euro prices instead of dollar.

Thanks in advance!


Elis Regina January 10, 2017

Hi guys. This is really helpful. Do you by any chance have a scraper for the actual text of the reviews? Im working on a text mining Project for a specific Hotel
Thanks a lot


Prakash Anand August 31, 2017

How can get all the hotels. This is giving me first page of results. Plz help.


Kentaro September 2, 2017

Hi.This is really helpful. Many thanks.
Is it possible to explain about the form_data? I need to change them to adjust to my needs.


Guy Malou January 2, 2018

I am a web developer and I happen to scratch web with other API. I would like to learn how to do it with python 2.7 that I installed and also pip except that I have trouble installing LXML because the download lxml-4.1.1-cp27-cp27m-win32.whl (3.2mb) n did not succeed and this sends me a message Exception:
Traceback (most recent call last):
i start in python and i would really like to help and many thanks


A. January 15, 2018

Hellom I’m getting “error: unrecognized arguments: Boston”
from the updated code, what could it mean?


    A. January 15, 2018

    Nevermind, works like a charm, thanks for sharing


Walker Aguilar April 5, 2018

Is posible get the image of the hotel?


Alex Galey April 10, 2018

Thank you for this artcile and code, I am not able to scrap data : Installation Ok – URL found Ok – Parsing Data Ok – tripadvisor_data.csv Empty (only first line).
I tried with different cities for different dates.

I am also getting warning :
/usr/local/lib/python2.7/dist-packages/urllib3/ InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See:


nadia April 10, 2018

I think my code has been blocked by tripadvisor or i have been blacklisted. Now , is there any alternative


Bitact April 25, 2018

Mine too


Comments or Questions?

Turn the Internet into meaningful, structured and usable data   

ScrapeHero Logo

Can we help you get some data?