const cheerio = require("cheerio");

const Parser = {
    search: body => {
        let data = []
        const $ = cheerio.load(body)
        const imgTags = $(".search-product img.search-product-wrap-img")
        imgTags.map((k, v) => {
            let img = $(v);
            data.push({
                title: img.attr('alt'),
                img: img.attr('src'),
                link: img.parent().parent().parent().attr('href')
            });

        })
        console.log('- fetching ' + data.length + ' search list completed')
        return data
    },
    
}

module.exports = Parser