Created
September 3, 2020 03:51
-
-
Save sysnucleus/e593916ae89d22cc9daf079adbba2aaf to your computer and use it in GitHub Desktop.
Codes to extract reviewer submitted images from TripAdvisor using WebHarvy
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
// 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