Forum Replies Created

  • When scraping product images from Americanas Brazil, Selenium allows you to interact with the page and locate the image elements using xpath or css selectors. Product images are typically in img tags, and you can extract the src attribute to get the image URL. It’s useful to check for multiple images if the product has variations.

    from selenium import webdriver
    # Set up the driver
    driver = webdriver.Chrome()
    # Navigate to the product page
    driver.get('https://www.americanas.com.br/produto-page')
    # Scrape image URLs
    images = driver.find_elements_by_css_selector('.product-images img')
    for img in images:
        print('Product Image URL:', img.get_attribute('src'))
    driver.quit()
    
  • To scrape the price from Mercado Livre Brazil, target the element containing the product price, which is typically wrapped in a span tag. Puppeteer enables you to extract text content once the page is fully loaded. You can use page.$eval() to capture the price and ensure it’s formatted correctly with the currency symbol.

    const puppeteer = require('puppeteer');
    (async () => {
        // Open the browser
        const browser = await puppeteer.launch({ headless: true });
        const page = await browser.newPage();
        await page.goto('https://www.mercadolivre.com.br/product-page');
        // Scrape the product price
        const price = await page.$eval('.price-tag-fraction', el => el.innerText);
        console.log('Product Price:', price);
        await browser.close();
    })();