info@worthwebscraping.com
(+91) 79841 03276

How to Scrape TripAdvisor Hotels Data using Python

How to Scrape TripAdvisor Hotels Data using Python

Download Python Script

Send download link to:

Tripadvisor is the most popular website to search for best hotels, restaurants, sight-seeing places, adventure gaming and almost anything for a nice trip. Whenever someone plans a trip to a new city, country it is almost a ritual to check for the best places and things to do on tripadvisor. Millions of people visit the website every year looking to make their trips memorable. Also, millions of people put their experiences, reviews of places on website. Because the website is so popular more and more hotels, restaurants and other travel businesses are trying to get listed on the website and maintain a good status as good reviews here can benefit them a lot. Let us learn about scrape TripAdvisor hotels data.

In this tutorial we will go to tripadvisor.com and search for hotels in Paris and grab the details like Hotel name, average rating, number of reviews, price.

https://www.tripadvisor.in/Hotels-g187147-Paris_Ile_de_France-Hotels.html

See the complete code below or watch the video for detailed explanation: Import Libraries

import requests
from bs4 import BeautifulSoup as soup
Send get request:
html = requests.get('https://www.tripadvisor.in/Hotels-g187147-Paris_Ile_de_France-Hotels.html')

Grab hotel name:

hotel = []
for name in bsobj.findAll('div',{'class':'listing_title'}):
  hotel.append(name.text.strip())

hotel

Output:

Grab average ratings:

ratings = []
for rating in bsobj.findAll('a',{'class':'ui_bubble_rating'}):
  ratings.append(rating['alt'])

ratings

Output:

Grab number of reviews:

reviews = []
for review in bsobj.findAll('a',{'class':'review_count'}):
  reviews.append(review.text.strip())

reviews

Output:

Price:

price = []

for p in bsobj.findAll('div',{'class':'price-wrap'}):
  price.append(p.text.replace('₹','').strip()) 
price[:5]

Output:

Create pandas data frame:

import pandas as pd
d1 = {'Hotel':hotel,'Ratings':ratings,'No_of_Reviews':reviews,'Price':price}
df = pd.DataFrame.from_dict(d1)

Output:

Hope you learn about to scrape TripAdvisor Hotels data. Are you in need of data from TripAdvisor then our TripAdvisor scraping services can scrape data for you and provide you in XLS and CSV format. Also look at our previously scraped data(sample data) for better understanding.