DEV Community

Алексей Спинов
Алексей Спинов

Posted on

How to Scrape Tripadvisor Hotel and Restaurant Reviews

Tripadvisor has 1B+ reviews across hotels, restaurants, and attractions.

Tripadvisor Content API

Tripadvisor offers a Content API (requires approval):

  • Location search
  • Reviews and ratings
  • Photos
  • Prices

Alternative: HTML Parsing

Tripadvisor pages are server-rendered:

const cheerio = require("cheerio");
const res = await fetch(url, { headers: { "User-Agent": "Mozilla/5.0" } });
const $ = cheerio.load(await res.text());

const reviews = $(".review-container").map((i, el) => ({
  title: $(el).find(".noQuotes").text(),
  rating: $(el).find(".ui_bubble_rating").attr("class")?.match(/bubble_(\\d+)/)?.[1],
  text: $(el).find(".partial_entry").text().trim(),
  date: $(el).find(".ratingDate").attr("title")
})).get();
Enter fullscreen mode Exit fullscreen mode

Use Cases

  1. Hospitality market research
  2. Competitor review analysis
  3. Travel recommendation engines
  4. Location-based marketing
  5. Guest satisfaction tracking

Resources


Need Tripadvisor or travel review data? $20. Email: Spinov001@gmail.com | Hire me

Top comments (0)