Skip to content

Instantly share code, notes, and snippets.

@wlm623
Created October 17, 2017 17:53
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 wlm623/7341338ceb34dced1bf0a926e88594b2 to your computer and use it in GitHub Desktop.
Save wlm623/7341338ceb34dced1bf0a926e88594b2 to your computer and use it in GitHub Desktop.
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