[Python] Pulling reviews from yelp - beautifulsoup

Discussão em 'Python' iniciado por Stack, Janeiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    So im trying to grab all the reviews from yelp for the hotel: https://www.yelp.com/biz/capri-laguna-laguna-beach

    I have my code below, but I'm unable to pull all the reviews.. I am only able to pull one.. can someone please assist?

    I would ideally love to pull all the yelp reviews for this establishment


    import time
    import random
    from bs4 import BeautifulSoup as bs

    import urllib.request as url


    html = urllib.request.urlopen('https://www.yelp.com/biz/capri-laguna-laguna-beach').read().decode('utf-8')

    soup = bs(html, 'html.parser')

    relevant= soup.find_all('p', class_='comment__09f24__gu0rG css-qgunke')

    for div in relevant:
    for html_class in div.find_all('span',class_="raw__09f24__T4Ezm"):
    text = html_class.find('span')
    review = html_class.getText(

    print(review)

    Continue reading...

Compartilhe esta Página