javascript - JQuery.contents not working using jsdom -
this code work in browser, in node.js (using jsdom + crawler), returns undefined
$('div').find('.class').contents()[0].wholetext
any idea on how solve this?
btw, when try stringify in nodejs, returns error circular defintion
the full code:
var crawler = require("crawler").crawler; var data = {} var c = new crawler({ maxconnections: 10, skipduplicates: true, // called each crawled page callback: function(error, result, $) { // $ jquery instance scoped server-side dom of page $("#link > ul > li > a").each(function(index, a) { c.queue(a.href); }); $("[id^=enfr]").each(function(index, a){ var fr = $(this).find('.frwrd strong').html().replace(/<(?:.|\n)*?>/gm, '') var = $(this).find('.towrd').contents()[0] console.log(fr + '\t\t\t\t\t' + to) }) } }); // queue 1 url, default callback c.queue("http://www.wordreference.com/enfr/0");
ok resolved using "stock" dom library:
var = $(this).find('.towrd').get(0).firstchild.nodevalue
Comments
Post a Comment