r/webscraping • • 4d ago

Looking for a 100% FREE Python Script to Scrape TripAdvisor

Hi everyone!

I'm looking for a completely FREE solution to scrape places and businesses from TripAdvisor across multiple countries using Python.

I need to collect:

- Place/business names and descriptions

- Categories (restaurants, attractions, museums, landmarks, hotels, etc.)

- Country, city, and full address

- Geographic coordinates (latitude and longitude)

- Phone numbers and websites (if available)

- TripAdvisor URLs

- Photos and image URLs

- Ratings and number of reviews

I'm considering Selenium, BeautifulSoup, Playwright, Requests, or any other Python scraping tools.

My requirements:

- 100% FREE — no paid APIs, subscriptions, or premium services.

- Open-source tools and libraries.

- Ability to discover places automatically by country and city.

- A working Python script that I can run locally.

Has anyone done something similar?

Could you please share a working script, GitHub repository, or code examples? Any help would be greatly appreciated!

Thank you!

0 Upvotes

13 comments sorted by

4

u/bluewhalefunk 3d ago

lol, you want to scrape a high value target, that some one else has solved and give you to run a a push of a button for everything you need without you having to do anything.

These next to never exist, you know that right?

-2

u/SurveyElectronic3845 3d ago

Bro i was not asking for something ready i was aking for guidance

5

u/RobSm 3d ago

"100% Free python script" is not guidance.

But wait! You could build one yourself, use AI and google and develop one. Then you will be able to upload it here for everyone else and obviously For FREE.

-1

u/SurveyElectronic3845 3d ago

Okay my bro i will do it once i create cause i am not greedy

2

u/bluewhalefunk 1d ago

ok fair enough then I read it it wrongly or you were not clear.

Go find a wall, bang your head against it, keep doing so until the project is done. That is how major scraping projects go.

Start Http requests, I imagine tripadvisor won't work and you'll need a browser, but maybe. Then code something, when it doesn't work, figure out, move on until it doesn't work again, repeat.

I know that's not the advise you want, but that is how it's done.

1

u/Takeoded 20h ago

Has anyone done something similar?

Yup. I used chrome-php/chrome/DOMDocument/XPath

For example, this yields Tripadvisor's "Essentials" list of Supreme Korea:

<?php declare(strict_types=1);

require_once 'vendor/autoload.php';

$chromiumPath ='/usr/bin/chromium'; // '/snap/bin/chromium';
$factory = new \HeadlessChromium\BrowserFactory($chromiumPath);
$browser = $factory->createBrowser(
    [
        'headless' => false,
        'customFlags' => [
            // docker compatibility flags
            '--no-sandbox',
            '--disable-gpu-sandbox',
            '--disable-setuid-sandbox',
            '--disable-dev-shm-usage',
            '--disable-breakpad',
            '--disable-crash-reporter',
            '--no-crashpad',
            // anti automation detection flags
            '--disable-blink-features=AutomationControlled',
            '--disable-infobars',
            '--unsafely-disable-devtools-self-xss-warnings',
        ],
    ],
);
$page = $browser->createPage();
function handleCaptcha($page)
{
    // first check that page load is complete
    for(;;){
        $readyState = $page->evaluate('document.readyState')->getReturnValue();
        if ($readyState === 'complete') {
            break;
        }
        usleep(10000);
    }
    $html = $page->getHTML();
    // We detected unusual activity from your device or network
    if(str_contains($html, 'https://geo.captcha-delivery.com/captcha/')) {
        echo "Captcha detected!\n";
        echo "A human must solve the captcha, and press enter.\n";
        fgets(STDIN);
        handleCaptcha($page);
    }
}
$page->navigate('https://www.tripadvisor.com/Tourism-g294443-North_Korea-Vacations.html')->waitForNavigation();
handleCaptcha($page);
$html = $page->getHTML();
$dom = new \DOMDocument();
@$dom->loadHTML($html);
$xp = new \DOMXPath($dom);
$parsed = [];
foreach ($xp->query('//a[contains(@href,"Attraction_Review")]') as $a) {

    $item = [];

    // URL
    $item['url'] = $a->getAttribute('href');

    // Title
    $titleNode = $xp->query('.//*[@data-automation="cardHeaderTitle"]//div[contains(@class,"BMQDV")]', $a);

    if ($titleNode->length) {
        $item['title'] = trim($titleNode->item(0)->textContent);
    }

    // Rating
    $ratingNode = $xp->query('.//*[@data-automation="bubbleRatingValue"]//span', $a);

    if ($ratingNode->length) {
        $item['rating'] = trim($ratingNode->item(0)->textContent);
    }

    // Review count
    $reviewNode = $xp->query('.//*[@data-automation="bubbleReviewCount"]//span', $a);

    if ($reviewNode->length) {
        $item['reviews'] = (int) preg_replace('/\D/', '', $reviewNode->item(0)->textContent);
    }

    // Category
    $catNode = $xp->query('.//span[contains(@class,"biGQs")]', $a);

    if ($catNode->length) {
        $item['category'] = trim($catNode->item($catNode->length - 1)->textContent);
    }

    // First image
    $imgNode = $xp->query('.//img[@src and not(starts-with(@src,"data:image"))]', $a);

    if ($imgNode->length) {
        $item['image'] = $imgNode->item(0)->getAttribute('src');
    }

    $parsed[] = $item;
}
echo json_encode($parsed, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);

yields:

$ php lol.php
Captcha detected!
A human must solve the captcha, and press enter.

[
    {
        "url": "/Attraction_Review-g294443-d324944-Reviews-Demilitarized_Zone-North_Korea.html",
        "title": "Demilitarized Zone",
        "rating": "4.5",
        "reviews": 133,
        "category": "Historic Sites, Points of Interest & Landmarks",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/04/44/ca/f8/demilitarized-zone.jpg?w=600&h=400&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d459854-Reviews-Juche_Tower-Pyongyang.html",
        "title": "Juche Tower",
        "rating": "4.3",
        "reviews": 310,
        "category": "Monuments & Statues",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/06/d9/47/f5/tower-of-the-juche-idea.jpg?w=600&h=-1&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d1957353-Reviews-Kim_Il_sung_Square-Pyongyang.html",
        "title": "Kim Il-sung Square",
        "rating": "4.2",
        "reviews": 161,
        "category": "Points of Interest & Landmarks",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/05/61/5a/07/kim-il-sung-square.jpg?w=600&h=-1&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d9882726-Reviews-Mansudae_Grand_Monument-Pyongyang.html",
        "title": "Mansudae Grand Monument",
        "rating": "4.4",
        "reviews": 106,
        "category": "Monuments & Statues, Points of Interest & Landmarks",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/19/4d/e9/4f/img-20190908-125656-largejpg.jpg?w=600&h=400&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d1967782-Reviews-Tanjun_Mausoleum-Pyongyang.html",
        "title": "Tanjun Mausoleum",
        "rating": "4.9",
        "reviews": 13,
        "category": "Historic Sites",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/17/36/84/0d/photos-only-permitted.jpg?w=600&h=400&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d4783801-Reviews-Victorious_Fatherland_Liberation_War_Museum-Pyongyang.html",
        "title": "Victorious Fatherland Liberation War Museum",
        "rating": "4.3",
        "reviews": 174,
        "category": "Military Museums",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/08/d1/b5/25/victorious-fatherland.jpg?w=600&h=400&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d2529100-Reviews-Geumsusan_Memorial_Palace-Pyongyang.html",
        "title": "Geumsusan Memorial Palace",
        "rating": "4.5",
        "reviews": 86,
        "category": "Points of Interest & Landmarks",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/06/d9/4f/ab/geumsusan-memorial-palace.jpg?w=600&h=-1&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d2264518-Reviews-Rungrado_May_Day_Stadium-Pyongyang.html",
        "title": "Rungrado May Day Stadium",
        "rating": "4.4",
        "reviews": 21,
        "category": "Arenas & Stadiums",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/0b/0f/df/8e/outside-view-of-stadium.jpg?w=600&h=400&s=1"
    },
    {
        "url": "/Attraction_Review-g3685359-d324936-Reviews-Mount_Kumgang-Kangwon_Province.html",
        "title": "Mount Kumgang",
        "rating": "4.5",
        "reviews": 13,
        "category": "Monuments & Statues, Mountains",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/04/7b/df/a9/mount-kumgang.jpg?w=600&h=400&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d459971-Reviews-Triumphal_Arch-Pyongyang.html",
        "title": "Triumphal Arch",
        "rating": "3.8",
        "reviews": 156,
        "category": "Monuments & Statues",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/0a/06/90/94/triumphal-arch.jpg?w=600&h=-1&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d1209066-Reviews-Monument_to_the_Korean_Workers_Party-Pyongyang.html",
        "title": "Monument to the Korean Workers Party",
        "rating": "3.9",
        "reviews": 103,
        "category": "Architectural Buildings, Monuments & Statues",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/04/69/68/46/interesting-statue.jpg?w=600&h=-1&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d459975-Reviews-Kim_Il_Sung_Stadium-Pyongyang.html",
        "title": "Kim Il Sung Stadium",
        "rating": "4.3",
        "reviews": 48,
        "category": "Arenas & Stadiums",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/09/4e/41/81/kim-il-sung-stadium.jpg?w=600&h=400&s=1"
    },
    {
        "url": "/Attraction_Review-g294443-d324944-Reviews-Demilitarized_Zone-North_Korea.html",
        "rating": "4.5",
        "reviews": 133,
        "category": "(133)",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/04/44/ca/f8/demilitarized-zone.jpg?w=300&h=300&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d459854-Reviews-Juche_Tower-Pyongyang.html",
        "rating": "4.3",
        "reviews": 310,
        "category": "(310)",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/06/d9/47/f5/tower-of-the-juche-idea.jpg?w=300&h=300&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d12373599-Reviews-Koryo_Tours-Pyongyang.html",
        "rating": "5.0",
        "reviews": 266,
        "category": "(266)",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/0f/23/76/c9/koryo-tours.jpg?w=300&h=-1&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d2529100-Reviews-Geumsusan_Memorial_Palace-Pyongyang.html",
        "rating": "4.5",
        "reviews": 86,
        "category": "(86)",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/06/d9/4f/ab/geumsusan-memorial-palace.jpg?w=300&h=300&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d9882726-Reviews-Mansudae_Grand_Monument-Pyongyang.html",
        "rating": "4.4",
        "reviews": 106,
        "category": "(106)",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/19/4d/e9/4f/img-20190908-125656-largejpg.jpg?w=300&h=300&s=1"
    },
    {
        "url": "/Attraction_Review-g294444-d4783801-Reviews-Victorious_Fatherland_Liberation_War_Museum-Pyongyang.html",
        "rating": "4.3",
        "reviews": 174,
        "category": "(174)",
        "image": "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/08/d1/b5/25/victorious-fatherland.jpg?w=300&h=300&s=1"
    }
]

1

u/[deleted] 4d ago

[removed] — view removed comment

1

u/webscraping-ModTeam 4d ago

💰 Welcome to r/webscraping! Referencing paid products or services is not permitted, and your post has been removed. Please take a moment to review the promotion guide. You may also wish to re-submit your post to the monthly thread.