News Feed Forums General Web Scraping Scrape product name, discount, and shipping from Submarino Brazil using Node.js?

  • Scrape product name, discount, and shipping from Submarino Brazil using Node.js?

    Posted by Dyson Baldo on 12/12/2024 at 7:39 am

    To scrape the product name from Submarino Brazil, you can use Cheerio in Node.js to extract the text from the div or span containing the product title. This is often wrapped in specific classes that you can target using Cheerio’s $(‘.class-name’) syntax. After fetching the page using axios, parse the HTML and extract the product name.

    const axios = require('axios');
    const cheerio = require('cheerio');
    async function scrapeProductName() {
        const { data } = await axios.get('https://www.submarino.com.br/produto-page');
        const $ = cheerio.load(data);
        const productName = $('.product-title').text();
        console.log('Product Name:', productName);
    }
    scrapeProductName();
    
    Rayna Meinrad replied 1 week, 1 day ago 3 Members · 2 Replies
  • 2 Replies
  • Jerilyn Shankar

    Member
    12/13/2024 at 10:20 am

    To scrape the discount from Submarino Brazil, you can use Cheerio to look for the element containing the discount percentage, which is typically wrapped in a span or div. The discount information may be shown with a percentage off and might appear only if the product is on sale. By querying the relevant HTML element, you can extract the discount value.

    const axios = require('axios');
    const cheerio = require('cheerio');
    async function scrapeDiscount() {
        const { data } = await axios.get('https://www.submarino.com.br/produto-page');
        const $ = cheerio.load(data);
        const discount = $('.discount-percentage').text();
        console.log('Discount:', discount);
    }
    scrapeDiscount();
    
  • Rayna Meinrad

    Member
    12/14/2024 at 7:21 am

    To scrape shipping details from Submarino Brazil, use Cheerio to find the shipping section of the page. The shipping information, including estimated delivery times and shipping fees, is usually contained in a specific div or span. Extract this information by selecting the appropriate class or tag that holds the shipping text.

    const axios = require('axios');
    const cheerio = require('cheerio');
    async function scrapeShipping() {
        const { data } = await axios.get('https://www.submarino.com.br/produto-page');
        const $ = cheerio.load(data);
        const shipping = $('.shipping-info').text();
        console.log('Shipping Details:', shipping);
    }
    scrapeShipping();
    

Log in to reply.