Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment