I've created a small program to check some URLs. It does what I want however I'd like to change the design of it - at the moment I have to create new variables each time I want to add a url , which isn't really ideal - see below example. Instead, I'd like an array of URLs.
But I'm unsure of what design pattern I'd use in this case - as I need to keep the state of each of the URLs.
let minutes = 10, the_interval = minutes * 60 * 1000;
const url1 = "https://example.com/1";
const url2 = "https://example.com/2"";
const url3 = "https://example.com/3";
(async () => {
// Get starting pages - for the very first run
let url1Start = await getUrlContent(url1)
let url2Start = await getUrlContent(url2)
let url3Start = await getUrlContent(url3)
setInterval(async function () {
url1Start = await doCheck(url1, url1Start)
url2Start = await doCheck(url2, url2Start)
url3Start = await doCheck(url3, url3Start)
}, the_interval);
})();
Basically, I'm just getting the state of the page at the stage, then doing the same after every x minutes and comparing it with the original.
Any ideas would be appreciated.
Thanks.
Aucun commentaire:
Enregistrer un commentaire