Skip to content

Instantly share code, notes, and snippets.

@tomoya55
Created June 8, 2020 03:43
Show Gist options
  • Save tomoya55/48b6cb06ba68f11cf0713f17a207b555 to your computer and use it in GitHub Desktop.
Save tomoya55/48b6cb06ba68f11cf0713f17a207b555 to your computer and use it in GitHub Desktop.
Parse Amazon unlimited loaned books
const title = (e) => $('div.a-column:nth-child(2) .a-row:nth-child(1) span', e).text().trim();
const authors = (e) => $('div.a-column:nth-child(2) .a-row:nth-child(2) span', e).text().trim();
const started = (e) => $('div.a-column:nth-child(3) .a-row:nth-child(1) span', e).text().trim();
const data = [];
$('#itemsList .item').each((i, e) => data.push({title: title(e), authors: authors(e), started: started(e)}));
$('<a></a>')
.attr('id','downloadJSON')
.attr('href','data:application/json;charset=utf8,' + encodeURIComponent(JSON.stringify(data)))
.attr('download','unlimited.json')
.appendTo('body');
$('#downloadJSON').get(0).click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment