(支持Chrome 77版本)现在支持 作为 pageLoadStrategy 。
如您所提,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")