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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -