如何用selenium python向下滚动表格?

时间:2018-04-01 08:28:08

标签: python python-3.x selenium

请检查scrrenshot https://www.screencast.com/t/dNgVy1xWON

https://www.screencast.com/t/6P0MUQoO

PAGE = 1
SCROLL_PAUSE_TIME = 4

# Get scroll height
last_height = driver.execute_script("return document.body.scrollHeight")

while True:
    print("Scrolling to page %s" % PAGE)

    # Scroll down to bottom
    # if time.time() // 9 % 5 == 0:
    #     print("window scrolling to bottom")
    #     break

    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

    # Wait to load page
    time.sleep(SCROLL_PAUSE_TIME)

    # Calculate new scroll height and compare with last scroll height
    new_height = driver.execute_script("return document.body.scrollHeight")
    if new_height == last_height:
        break

    last_height = new_height
    PAGE += 1

我需要向下滚动,但这不会做任何事情

0 个答案:

没有答案