🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] **重要的js代码** ~~~ * js = "window.scrollTo(x, y)" ~~~ x为水平拖动距离,y为垂直拖动距离 ~~~ * js = "var q=document.documentElement.scrollTop=n" ~~~ n为从顶部往下移动滚动举例 **执行js代码** ~~~ driver.execute_script(js) ~~~ **hao123持续下拉** ~~~ from selenium import webdriver import time # 创建浏览器 driver = webdriver.Firefox() # 访问好123 url = 'https://www.hao123.com/' driver.get(url) for i in range(100): # x管水平,y管垂直 js = 'window.scrollTo(0,%s)'%(i*100) driver.execute_script(js) time.sleep(0.5) # js1= "var q=document.documentElement.scrollTop=0" # driver.execute_script(js1) driver.quit() ~~~