Forum Replies Created

  • To obtain the price, locate the element containing the pricing information, which is often within a span or div tag with a class indicating price. Using Nokogiri, you can select this element and extract the text, ensuring you handle any currency symbols appropriately.

    require 'net/http'
    require 'nokogiri'
    # Fetch the product page
    url = URI('https://www.magazineluiza.com.br/produto-page')
    response = Net::HTTP.get(url)
    # Parse the HTML
    doc = Nokogiri::HTML(response)
    # Extract the product price
    price = doc.at_css('.product-price').text.strip
    puts "Price: #{price}"
    
  • 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)