C
C
CODER5412018-04-17 17:11:21
HTML
CODER541, 2018-04-17 17:11:21

How to read text between HTML tags on Node.js(cheerio)?

I am writing a parser. And I need to pull out the line "Reluctant heiress [01-02 of 08] (2018) WEBRip-AVC from Files-x" how to do this?
HTML code:

<a href="/torrent/626682/naslednica-ponevole-01-02-iz-08-2018-webrip-avc-ot-files-x">Наследница поневоле [01-02 из 08] (2018) WEBRip-AVC от Files-x </a>

For example, in order to pull out a magnet link and a link to a torrent file, I have this code:
const request = require('request-promise');
const cheerio = require('cheerio');
request('http://s.new-rutor.org/').then(res => {
  const $ = cheerio.load(res)
  const links = $('a')
  
  links.each(i => {
    const link = links.eq(i).attr('href')
    if (link && link.includes('magnet')) {
      console.log(link)
    }
  
  })

  const  torrents = $('a')
  torrents.each(i=>{
      const torrent =torrents.eq(i).attr('href')
      if(torrent && torrent.includes('/torrent')) {
        console.log("Torrent is here:")
        console.log(torrent)
      }

    })
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexalexes, 2018-04-17
@CODER541

This text is not between tags, this is the content of the tag itself.
links.eq(i).html() - isn't it?
Ask questions that are answered in the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question