I wanted to extract the metatag and check whether 'viewport' is present in the meta tag in nodejs. I searched and couldn't find any efficient method. Any suggestions?
Maybe this would be helpful:
function getMeta(){
var el = document.getElementsByTagName('head'),
ch = el[0].children;
for (let e=0; e<ch.length; e++) {
if ( ch[e].tagName.toLowerCase() === 'meta' && ch[e].getAttribute('name') === "viewport"){
console.log(ch[e]);
}
}
}
and just call function as
getMeta();