Guest User

Untitled

a guest
Oct 18th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. loadmore_counter = 0
  2. y = 0 #y value will be used as a vertical position in the browser window
  3. while loadmore_counter <= numloads: #numloads is previously set based on how many reviews a school is listed to have
  4. loadmore = driver.find_element_by_xpath('//*[@data-school-id='+ sid + ']') #this is the xpath of the Load More Button
  5. location = loadmore.location_once_scrolled_into_view #dictionary with 'x' and 'y' keys associated with location values
  6. #the location_once_scrolled_into_view function returns how much further we need to scroll
  7. y += loaction['y'] #so we add the y value returned to the previous y
  8. driver.execute_script("window.scrollTo(0, {0});".format(y)) #JavaScript command to scroll
  9. loadmore.click()
  10. loadmore_counter += 1
Add Comment
Please, Sign In to add comment