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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { fetch } from "https://esm.town/v/std/fetch";
let { californiaBusinessNotificationsLast } = await import("https://esm.town/v/tmcw/californiaBusinessNotificationsLast");
export const californiaBusinessNotifications = (async () => {
const { parse } = await import("https://deno.land/x/xml/mod.ts");
const res: any = await fetch(
"https://bizfileonline.sos.ca.gov/api/FilingDetail/business/4603/false",
{
headers: {
Accept: "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
"User-Agent": "Mozilla/5.0",
},
},
).then((r) => r.text()).then(parse);
const list = res.DRAWER.DRAWER_DETAIL_LIST.DRAWER_DETAIL.map((detail) => {
return `## ${detail.LABEL}${detail.ALERT_YN ? " (alert)" : ""}
${detail.VALUE}`;
});
const lastValue = new Set(
californiaBusinessNotificationsLast || [],
);
let newEntries = [];
let removedEntries = [];
for (let val of list) {
if (!lastValue.has(val)) {
newEntries.push(val);
}
}
for (let val of lastValue.values()) {
if (!list.includes(val)) {
removedEntries.push(val);
}
}
californiaBusinessNotificationsLast = list;
if (newEntries.length || removedEntries.length) {
console.email(
`
Removed entries:
${removedEntries.join("\n\n")}
New entries:
${newEntries.join("\n\n")}`,
`Change in California business records!`,
);
}
return list;
})();