Created
June 29, 2022 11:49
-
-
Save sysnucleus/15991d5f19388909f26e10efc0b43f94 to your computer and use it in GitHub Desktop.
WebHarvy Codes for Google Reviews Scraping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pagination JavaScript Code | |
------------------------------- | |
lists = document.getElementsByClassName('gws-localreviews__general-reviews-block'); | |
list = lists[lists.length-1]; | |
list.children[list.childElementCount-1].scrollIntoView(); | |
// Code to expand all reviews | |
--------------------------------- | |
els = document.getElementsByClassName('review-more-link'); | |
for (i = 0; i < els.length; i++) { | |
els[i].click(); | |
} | |
// Code to collate all reviews | |
--------------------------------- | |
var groups = document.getElementsByClassName('gws-localreviews__general-reviews-block'); | |
var parent = groups[0]; | |
for (var i = groups.length - 1; i >= 1; i--) { | |
var group = groups[i]; | |
for (var j = group.children.length - 1; j >= 0; j--) { | |
parent.appendChild(group.children[j]); | |
} | |
} | |
// RegEx to get rating | |
------------------------- | |
aria-label="Rated ([^\s]*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment