Runs every 30 days
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
import { set } from "https://esm.town/v/std/set?v=11";
import { fetchTextWithEncoding } from "https://esm.town/v/stu43005/fetchTextWithEncoding";
import * as cheerio from "npm:cheerio@1.0.0";
export async function genHololiveAnniversaryData() {
const body = await fetchTextWithEncoding(
"https://seesaawiki.jp/hololivetv/d/%B5%AD%C7%B0%C6%FC",
{
encoding: "EUC-JP",
},
);
const $ = cheerio.load(body);
const table = $("#page-body .user-area table tr")
.toArray()
.map((row) => $("td,th", row).toArray().map((td) => $(td).text()))
.reduce((acc, cur, index) => {
if (index === 0) {
acc.header = cur.map((v) => v.replace(/\(.*$/, ""));
}
else {
const item = Object.fromEntries(cur.map((v, i) => [acc.header[i], v]));
acc.rows.push(item);
}
return acc;
}, {
header: [],
rows: [],
});
await set("hololiveAnniversaryData", table.rows);
return table.rows;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
August 17, 2024