1SCROLL_PAUSE_TIME = 0.5
2
3# Get scroll height
4last_height = driver.execute_script("return document.body.scrollHeight")
5
6while True:
7 # Scroll down to bottom
8 driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
9
10 # Wait to load page
11 time.sleep(SCROLL_PAUSE_TIME)
12
13 # Calculate new scroll height and compare with last scroll height
14 new_height = driver.execute_script("return document.body.scrollHeight")
15 if new_height == last_height:
16 break
17 last_height = new_height
18