1 #coding=utf-8 2 from selenium import webdriver 3 4 #滚动到浏览器顶部 5 js_top = "var q=document.documentElement.scrollTop=0" 6 7 #滚动到浏览器底部 8 js_bottom = "var q=document.documentElement.scrollTop=10000" 9 js_bottom2 = "window.scrollTo(0,document.body.scrollHeight)" 10 11 driver = webdriver.Chrome() 12 driver.get(url) 13 driver.execute_script(js_bottom) 14 driver.execute_script(js_top) 15 driver.close()