python3 selenium 加载特定元素 停止加载 执行[亲测有效]

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait       #WebDriverWait注意大小写
from selenium.webdriver.common.by import By


capa = DesiredCapabilities.CHROME
capa["pageLoadStrategy"] = "none"
driver=webdriver.Chrome(desired_capabilities=capa)  # 关键!记得添加
wait = WebDriverWait(driver, 20)
driver.get(url)
wait.until(EC.presence_of_element_located((By.XPATH, "//li[@id='SalesRank']")))  # 这里可选择多个selector

你可能感兴趣的:(笔记)