[Python] findAll() returning empty outputs

Discussão em 'Python' iniciado por Stack, Fevereiro 24, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to scrape the title, date, rating and actual review of each reviews form mouthshut. But I'm unable to extract anything under the title of page. The review is in
    tag under class 'more reviewdata'. I tried using multiple code snippet from similar stack problems, but still I'm getting an empty list when using the find()/findAll() function for my review data.

    Could anyone please suggest any solutions so as to not get empty lists when using the findAll() function for the specific classes needed?

    from bs4 import BeautifulSoup
    import requests

    url = 'https://www.mouthshut.com/product-reviews/berger-paints-reviews-925712965-page-4'
    response = requests.get(url)
    soup = BeautifulSoup(response.content, 'html.parser')

    #to extract the reviews
    for div in soup.find_all('div', class_='more reviewdata'):
    for p in div.find_all('p'):
    print(p.text)

    soup.find_all('i', class_='icon-rating rated-star') #to extract the rating

    #Similarly no outputs
    soup.findAll('div')

    Continue reading...

Compartilhe esta Página