I
I
it_pear_yurec2021-06-05 17:57:24
JavaScript
it_pear_yurec, 2021-06-05 17:57:24

Help with a parser?

There is js parser code

const axios = require('axios')
const cheerio = require('cheerio')
const path = require('path')

const parse = async() => {
    const getHTML = async(url) => {
        const { data } = await axios.get(url)
        return cheerio.load(data)
    }


    const selector = await getHTML(
        'google.com'
    );

    // selector('.card').each((i, element) => {
    //     const link = selector(element).find('.card__top').attr('href');
    //     console.log(link)
    // });

    selector('#description').each((i, element) => {
        const link = selector(element).find('p').text();
        console.log(link)
        console.log(link)
    });


}

parse();


the problem is that I have already collected a lot of links from nested pages, but I can’t figure out how to rewrite the parser so that I give it an array through which it would go and collect information from an array of links, and not just one link variable ( getHTML )?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question