Currently, I am utilizing casperjs to retrieve the content of a website that updates its values using websockets. Rather than attaching an event listener to each value, my goal is to scrape the entire website every 10 seconds.
Here is the code snippet I am using:
casper.waitForResource("http://website.com", function() {
getPrices(casper);
});
Within the getPrices function, I successfully extract the values and end with the following lines of code:
setTimeout(getPrices(casper), 5000);
The issue I am facing is that Casper appears to be disregarding the timeout and executing without delay. Additionally, I am concerned about the recursive nature of this solution potentially leading to a memory stack overflow in the long term.
Could anyone provide guidance on how to achieve this task more effectively?
Thank you!