Runs every 30 days
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { fetch } from "https://esm.town/v/std/fetch";
export const trackIphoneTradein = async () => {
const cheerio = await import("npm:cheerio@1.0.0-rc.12");
const page = await fetch(
"https://www.apple.com/shop/browse/overlay/tradein_landing/iphone_values",
).then((r) => r.text());
const $ = cheerio.load(page);
const rows = $("tr").map((row, elem) => {
const [name, val] = $(elem).find("td").map((idx, elem) => $(elem).text())
.toArray();
return { name, val };
}).toArray().filter((row) => row.name && row.val);
return rows;
};