Skip to content

Instantly share code, notes, and snippets.

@pfreema1
Last active July 19, 2023 07:38
Show Gist options
  • Save pfreema1/113a6405e0dc28c971182cd5b110532a to your computer and use it in GitHub Desktop.
Save pfreema1/113a6405e0dc28c971182cd5b110532a to your computer and use it in GitHub Desktop.
Get all amazon reviews on current page
/*
To use:
-open amazon product page
-click "see all reviews" and scroll to bottom of page to load all reviews
-copy and paste this code into console
-repeat on pages 2,3,4 etc
*/
let allReviews = "";
const scraper = function () {
const reviewEls = document.querySelectorAll('[data-hook="review"]');
if (reviewEls.length === 0) {
console.error("no reviews found!");
return;
}
reviewEls.forEach((reviewEl) => {
const csvRow = [];
const reviewTextEl = reviewEl.querySelector('[data-hook="review-body"]');
if (!reviewTextEl) {
console.error("no review text el found");
return;
}
allReviews += `\n\nREVIEW:`;
allReviews += `\n\n${reviewTextEl.innerText}`;
});
};
scraper();
console.log(allReviews);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment