selenium 下拉到页面最底端
selenium操控浏览器下拉到页面最底端:
https://www.cnblogs.com/TTyb/p/7662430.html
#!/usr/bin/env python # -*- coding: utf-8 -*- from selenium import webdriver import time if __name__ == '__main__': url = "http://blog.csdn.net/" browser = webdriver.Chrome() browser.get(url) browser.execute_script(""" (function () { var y = 0; var step = 100; window.scroll(0, 0); function f() { if (y < document.body.scrollHeight) { y += step; window.scroll(0, y); setTimeout(f, 100); } else { window.scroll(0, 0); document.title += "scroll-done"; } } setTimeout(f, 1000); })(); """) print("下拉中...") # time.sleep(180) while True: if "scroll-done" in browser.title: break else: print("还没有拉到最底端...") time.sleep(3)
本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/12938039.html