node.js - How can I find a tag inside a document in Javascript -
i want find out if document -which html file- has "some" tags. if so, want attributes.
i tried
var data = require('test.html'); if(data.tolowercase().indexof('<iframe') > -1|| data.tolowercase().indexof('<iframe>') > -1){ console.log('yeaaah exist'); // iframe attributes }
i able find if tag exist, how can attributes? on server side.
okay, got done using cheerio
var cheerio = require("cheerio"); var url = "./test.html"; // if not work try absolute url download(url, function(data) { if (data) { // console.log(data); var testdata = cheerio.load(data); // tag use testdata("sometag") console.log(testdata("sometag").length); } });
Comments
Post a Comment