Search code examples
htmlnode.jsweb-scrapingcheerio

Nodejs scraping options


I'm trying to build a scraping engine on node for my currency exchange graphs, at the moment I'm using request+cheerio, but since some bank websites don't use id/class'es in there html my code sometimes looks like:

var eurcur = parsedHTML('p','body')
                               .eq(1).children('table')
                                .children('tr').eq(2)
                                 .children('td')
                                  .children('table')
                                   .children('tr').eq(10)
                                    .children('td').eq(4).text()

Any thing else I could use?


Solution

  • You could use jsdom with a full-featured JQuery. This allows you to use more complex selectors that Cheerio doesn't support, including selectors like :first.

    However, some of your .children calls (with should be mergable, e.g.

    .children('td')
     .children('table')
    

    to

    .children('td > table')