I have a simple function to handle http request and I need to scrap html page from given url. I just copied the example from github . It works, it prints all found attributes but after that it prints "OK: Job complete" and shuts down the server. If I remove the each function, it doesn't stop the server, but I need to use it. Is this some bug in node.io (or in modules it uses) or am I doing something wrong?
function index(response, request){
require('node.io').scrape(function() {
this.getHtml('http://www.reddit.com/', function(err, $) {
var stories = [];
$('a.title').each(function(title) {
stories.push(title.text);
});
this.emit(stories);
});
});
}
Edit: I've managed to do the job with jsdom, but I'm still wondering about this problem...
感谢GitHub上的“ derekdr”用户, 此处描述了解决方案
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.