您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

不要等待在Python中使用Selenium加载页面

不要等待在Python中使用Selenium加载页面

支持Chrome 77版本)现在支持 作为 pageLoadStrategy

解决的问题1902:支持优先页面加载策略[Pri-2]

如您所提,click on elements and scrape data before the page has fully loaded在这种情况下,我们可以利用属性 。当Selenium认加载页面/ URL时,它将遵循认配置, 设置为 。Selenium可以从不同的代码开始执行下一行代码 。目前,Selenium支持3种不同的功能 ,我们可以通过 以下方式进行配置:

这是配置代码代码块 :

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'
caps = DesiredCapabilities().FIREFOX
# caps["pageLoadStrategy"] = "normal"  #  complete
caps["pageLoadStrategy"] = "eager"  #  interactive
# caps["pageLoadStrategy"] = "none"   #  undefined
driver = webdriver.Firefox(capabilities=caps, firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
driver.get("https://google.com")
python 2022/1/1 18:32:24 有602人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶