Diese jQuery wie Selektor "cheerio" versucht, die Kommentare von den Kommentarknoten in einer HTML-Seite zu bekommen.
$ ist das cheerio-Objekt. Wie kann es das tun? DankHolen Sie den Kommentar Element Text mit Cherrio Selektor
console.log($('*').contents().length); //reports back more than 1000
$('*').contents().filter(function() {
if (this.nodeType == 8) {
//the following gives null for every node found
console.log($(this).html());
//the following gives blank for every node found
console.log($(this).text());
}
});