Readme

Track iPhone trade-in prices

iPhone trade in values - to trade phones back to Apple themselves - fluctuate over time, and eventually they no longer accept certain kinds of phones. You can still trade in an iPhone 7 - released in 2016, about 6 years ago as of this writing. But no longer does an iPhone 6 have value back to Apple.

This tracks those values - it runs every month and records prices to iphoneTradeInValues, which I'll visualize once there's some data.

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;
};
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!
October 23, 2023