I'm using cheerio
to scrape the webpage in nodejs
. Now I've come across content of the web which is structured something like this,
<div data-content="123456"> ... </div>
<div data-content="142453"> ... </div>
<div data-content="192638"> ... </div>
<div data-content="152701"> ... </div>
<div data-content="172830"> ... </div>
note that data-content
attribute has different attribute values and within the div there is necessary data that i want to scrape out. How can i use cheerio to access the DOM attributes that are structured like this?
NOTE : I know using div
as a selector is possible. But i don't want to use div
as a selector with cheerio. i want to exclusively use data-content
as a selector to access DOM nodes.
This should work:
$('div[data-content]')