News Feed Forums General Web Scraping Scrape product name, review count, and availability from Casas Bahia Brazil?

  • Scrape product name, review count, and availability from Casas Bahia Brazil?

    Posted by Lalitha Kreka on 12/12/2024 at 8:04 am

    To scrape the product name from Casas Bahia Brazil, use BeautifulSoup in Python to extract the product title. The product name is often contained within a h1 or span tag with a specific class. You can easily grab it after fetching the HTML content using requests and parsing it with BeautifulSoup.

    import requests
    from bs4 import BeautifulSoup
    url = 'https://www.casasbahia.com.br/produto-page'
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    product_name = soup.find('h1', class_='product-name').text
    print('Product Name:', product_name)
    
    Jerilyn Shankar replied 1 week, 2 days ago 3 Members · 2 Replies
  • 2 Replies
  • Lucianus Hallie

    Member
    12/12/2024 at 11:16 am

    Scraping the review count from Casas Bahia Brazil involves finding the element that contains the number of reviews. This is typically found in a span or div tag with a class like review-count. After parsing the page with BeautifulSoup, you can extract the review count for each product.

    import requests
    from bs4 import BeautifulSoup
    url = 'https://www.casasbahia.com.br/produto-page'
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    reviews = soup.find('span', class_='review-count').text
    print('Review Count:', reviews)
    
  • Jerilyn Shankar

    Member
    12/13/2024 at 10:22 am

    To scrape availability from Casas Bahia Brazil, you can extract whether a product is in stock or out of stock. This is often found in a div or span tag that specifies availability status. Using BeautifulSoup, locate and extract this information to determine the product’s availability.

    import requests
    from bs4 import BeautifulSoup
    url = 'https://www.casasbahia.com.br/produto-page'
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    availability = soup.find('span', class_='availability-status').text
    print('Availability:', availability)
    

Log in to reply.