I have a simple web scraping script in Node.js that I'm trying to run in a loop:
var insp = require('node-metainspector');
var client = new insp("http://www.google.com", { timeout: 99999 });
var sleep = require("thread-sleep");
client.on("fetch", function(){
console.log("The title is:");
console.log(client.title);
});
client.on("error", function(err) {
console.log(err);
});
while(true) {
console.log("Checking...");
client.fetch();
sleep(10000);
}
When I run client.fetch()
outside of the loop it works perfectly fine, but whenever it's in a loop it doesn't work. There's no error thrown (I checked with try-catch). The rest of the lines in the loop execute. Why is this happening and how can I fix it?
via Shibolet 3
No comments:
Post a Comment