Created
October 17, 2017 17:53
-
-
Save wlm623/7341338ceb34dced1bf0a926e88594b2 to your computer and use it in GitHub Desktop.
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
loadmore_counter = 0 | |
y = 0 #y value will be used as a vertical position in the browser window | |
while loadmore_counter <= numloads: #numloads is previously set based on how many reviews a school is listed to have | |
loadmore = driver.find_element_by_xpath('//*[@data-school-id='+ sid + ']') #this is the xpath of the Load More Button | |
location = loadmore.location_once_scrolled_into_view #dictionary with 'x' and 'y' keys associated with location values | |
#the location_once_scrolled_into_view function returns how much further we need to scroll | |
y += loaction['y'] #so we add the y value returned to the previous y | |
driver.execute_script("window.scrollTo(0, {0});".format(y)) #JavaScript command to scroll | |
loadmore.click() | |
loadmore_counter += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment