Scrape JSON formatted list data from https://www.apple.com/iphone/compare/ for programmatic comparisons
Updated 2020/10/14
It'll need to be updated again if Apple changes the HTML structure of the page.
PRs welcome.
-
save-data.ts
Deno script for
- downloading the HTML of the compare page, or
- parsing JSON data from stdin
and saving the result locally to
./data
-
scrape.js
Userscript for scraping the data on the comparison website
- Navigate to https://www.apple.com/iphone/compare/ or to the cached html file in
./data/apple-iphone-compare-cached_<TIMESTAMP>.html
. You can cache a new one with:
deno run --allow-net --allow-read=. --allow-write=. save-data.ts download
-
Copy the contents of
scrape.user.js
and then paste and run it in your browser's JS console. -
Copy the console logged JSON string (60+ kB) to your clipboard.
-
Save it however you want, or piping from your CLI clipboard utility to the Deno script:
- Linux:
xclip
- macOS:
pbpaste
- Windows (My best guess for Powershell, but not sure 🤷♂️):
Get-Clipboard
Example:
pbpaste | deno run --allow-net --allow-read=. --allow-write=. save-data.ts stdin
- Analyze the JSON data file.