Reputation: 51
Please help, I want to scroll down to end of the bage but it stops. the code that i try is here
browser = webdriver.Chrome()
browser.get(url)
button = browser.find_element_by_tag_name("html")
old=""
new=" "
while len(new)>len(old):
old = browser.page_source
button.send_keys(Keys.END)
browser.implicitly_wait(40)
new = browser.page_source
Upvotes: 3
Views: 9470
Reputation: 5344
your script for that
driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
you can set no. of scrolls needed to get full length
scrolls = 4
while True:
scrolls -= 1
driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
time.sleep(3)
if scrolls < 0:
break
Upvotes: 6