Skip to content

Instantly share code, notes, and snippets.

@jamii
Created July 15, 2017 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamii/fe5d210f12a6a56a175aa040a03c950f to your computer and use it in GitHub Desktop.
Save jamii/fe5d210f12a6a56a175aa040a03c950f to your computer and use it in GitHub Desktop.
I finally got around to doing this. Goodreads has an import tool but it requires manually adding and re-rating each book.
Amazon really doesn't seem to want to show you your old ratings, but I finally found a page in Recommendations -> Improve your recommendations -> Items you've rated.
Then run this once:
``` js
localStorage.setItem("ratings", JSON.stringify({}))
```
And then run this until you run out of books:
``` js
ratings = JSON.parse(localStorage.getItem("ratings"))
reviews = document.getElementById("iyrCenter").children[3].children[0].children
for (i = 0; i < reviews.length - 2; i += 2) {
span = reviews[i].children[3].children[4].children[0].children[2]
asin = span.className.match(/starWrap_([\S]*)/)[1]
rating = span.className.match(/ys-blueStar_(\d)/)[1]
ratings[asin] = rating
}
localStorage.setItem("ratings", JSON.stringify(ratings))
document.getElementById("iyrNext").click()
```
And then run this once:
``` js
ratings = JSON.parse(localStorage.getItem("ratings"))
for (asin in ratings) {
console.log(asin, ",", ratings[asin]);
}
```
Copy and paste into ratings.csv. Add the header 'ISBN, My Rating'. Upload on https://www.goodreads.com/review/import.
(Not to mention the several hour diversion when I believed Goodreads claim to need ISBN numbers, and spent several hours signing up for Amazon APIs and writing Ruby-by-stack-overflow, only to discover that 'This item is not accessible through the Product Advertising API.'
It's fine. They understand ASIN.)
https://www.goodreads.com/review/list/51024288?shelf=read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment