Periodic Fetch
This example can be used as a basis for situations where you want to periodically fetch a document for automated processing. Fetching a document is an asynchronous activity, so in Conkeror, we use a coroutine to write it concisely. Warning: DO NOT ABUSE THIS CODE. USE IT ONLY WHERE YOU HAVE PERMISSION.
var fetch_timer = null;
function fetch_worker () {
var res = yield send_http_request(load_spec({uri: "http://example.com/"}));
dumpln(res.responseText);
}
function fetch_test () {
fetch_timer = call_at_interval(function () {
co_call(fetch_worker());
}, 300000); // interval of 5 minutes
}
function fetch_test_stop () {
timer_cancel(fetch_timer);
}To start the polling, call fetch_test. To stop the polling, call fetch_test_stop.