Im using casperjs, im trying to get the content of a website that changes its values using websockets. To accomplish this, instead of adding an event listener to each value, I just want to crawl the whole website every 10 seconds.
I have the following code:
casper.waitForResource("http://website.com",function() {
getPrices(casper);
});
Inside getPrices, I'm able to scrap the values, and at the end i have the following lines:
setTimeout(getPrices(casper),5000);
The problem is that I dont know why casper ignores the timeout. It just calls it without sleeping. On the other hand, I dont think that this is the greatest solution, since its recursive and in the long run, it will end up with a memory stack.
How can i accomplish this?
Thanks!