1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sendNotification from "https://esm.town/v/gwoods22/sendNotification";
import { blob } from "https://esm.town/v/std/blob";
import * as cheerio from "npm:cheerio@1.0.0";
const scrapeURL = "";
const blobKey = "";
export default async () => {
const variable: string = await blob.getJSON(blobKey) ?? "";
const response = await fetch(scrapeURL);
const body = await response.text();
const $ = cheerio.load(body);
const newVariable = $("selector").attr("id");
const arr = $("multi selector").toArray().map((x) => $(x).text().trim());
if (newVariable !== variable) {
await blob.setJSON(blobKey, newVariable);
const message = `New variable is ${newVariable}`;
await sendNotification("🔊 Update! 🔊", message, scrapeURL);
console.log(message);
} else {
console.log("Variable is still", variable);
}
};