Tripadvisor has a wide variety of data that you can scrape to do some competitor research, price comparison or create your own data set!
Today, we’ll show you how you can scrape a website like Tripadvisor to export data like hotel name, rating, price and price comparisons!
For this example, we are going to extract hotel data from Tripadvisor for hotels in Vancouver. Will extract the hotel name, price, and rating. We are going to export it as an excel/ CSV or JSON file
So let’s get started!
Web scraping TripAdvisor Data
While there are several web scraping tools, we think you’ll enjoy ParseHub! It’s free to use and has a suite of features like:
- IP Rotation
- Scheduling
- Cloud-based Scraping
- Many more!
- Once ParseHub is open, click on “New Project” and use the URL from the Tripadvisor.com result page. The page will now be rendered inside the app.
- Start by clicking on the first name of the first hotel name on the list. It will be highlighted in green to indicate it has been selected. On the left sidebar, rename your selection to “hotel_name”.
- Parsehub will now suggest the other data you want to be extracted in yellow. The rest of the hotels will now be highlighted in yellow. Click on the second hotel on the list to select them all. All hotels on the first page will be highlighted in green now. You are now collecting the name and URL listing of the models.
- Now let’s extract data like price, price comparisons and rating. To do this you will need to do a relative select command. Start by clicking on the PLUS(+) sign next to your hotel selection and choose the Relative Select command.
- Using the Relative Select command, click on the first hotel that is highlighted in orange and then on its price. An arrow will appear to show the association you’re creating.
- You might have to repeat this process for another hotel to fully train the scraper. On the left sidebar, rename your selection to “price”.
- Repeat steps 5-6 to pull more data for each Hotel to extract the data you want. We’re going to also extract the price comparisons and rating In this case. Your project should look somewhat like this:
Adding Pagination
If we were to start our project, we would only give extract the first page of hotels. We will now teach you how to add pagination to your web scraping project.
- Click the PLUS(+) sign next to your page selection and choose the “Select” command.
- Using the Select command, scroll all the way down to the Next Page link. Click on it to select it and rename your selection to next_button.
- Click on the icon next to your next_button selection to expand it. Delete the command under the next selection.
- Click on the PLUS(+) sign next to your next selection and add a Click command.
- A pop-up will appear asking you if this a “next page” link. Click on Yes and enter the number of times you’d like to repeat this process. In this case, we will repeat it 2 times.
Running your Scrape
It is now time to run your scrape. To do this, click on the green Get Data button on the left sidebar. Here you will be able to test, schedule, or run your scrape job.
For larger projects, we recommend that you always test your job before running it. In this case, we will run it right away.
Once your run is completed, you will be able to download it as an Excel or JSON file.
Enabling IP Rotation (Paid Feature)
If your web scraping project comes back blank, you may need to enable IP Rotation. You may be getting blocked from scraping the data, but IP rotation will allow you to still scrape the hotel data
If you’re getting blocked, let’s show you how you can enable IP Rotation.
Note: If you do enable IP rotation, your project will take longer to complete.
- Click on the gear icon, and then select settings
- Click on Rotate IP address
- A Popup will appear with to warning about your run speed, click on OK
Now run your project as normal.
Closing thoughts
Now you know how to scrape hotel data and export it into an excel/ CSV or JSON file.
We understand that web scraping projects can get quite complicated. If you run into any problems or have any questions, you can contact our customer support team using our live chat where we’ll be more than happy to assist you!
What will you scrape?
Happy Scrapping!