[Python] How to scrape the total number of customer reviews from the Amazon website on a...

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

  1. Stack

    Stack Membro Participativo

    I am trying to scrape the total number of customer reviews from the Amazon page, using python and beautiful soup library. The details like customer ratings, stars are getting scraped, but not the review count.

    def get_total_review(soup):
    try:
    # total_review1= soup.find("div", attrs={'id': 'filter-info-section'}).string.strip()
    total_review1= soup.find("div", attrs={'data-hook': 'cr-filter-info-section'}).string.strip()

    total_review = sototal_review1.find("div", attrs={'class':'a-row a-spacing-base a-size-base'}).string.strip()

    except AttributeError:
    total_review = ""

    return total_review


    [​IMG]

    I tried adding every particular id, class but the review count isn't getting displayed ('3,432' in this case, as you can see in the image):

    [​IMG]

    Continue reading...

Compartilhe esta Página