Skip to content

Instantly share code, notes, and snippets.

@sysnucleus
Created September 3, 2020 03:51
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 sysnucleus/e593916ae89d22cc9daf079adbba2aaf to your computer and use it in GitHub Desktop.
Save sysnucleus/e593916ae89d22cc9daf079adbba2aaf to your computer and use it in GitHub Desktop.
Codes to extract reviewer submitted images from TripAdvisor using WebHarvy
// RegEx to Follow links
href="([^"]*)
// More button click
document.getElementsByClassName('moreBtn')[0].click();
// Get images block
document.body.innerHTML = document.getElementsByClassName('inlinePhotosWrapper')[0].innerHTML;
// Resize images
var images = document.getElementsByClassName('centeredImg');
for (var i = images.length - 1; i >= 0; i--) {
var image = images[i];
var imgSrc = image.getAttribute('src');
imgSrc = imgSrc.replace('photo-l', 'photo-p');
image.setAttribute('src', imgSrc);
}
// RegEx to get image
src="(http[^"]*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment