我想提取一个人赫伯特·W·古奎斯特(Herbert W. Gullquist)的传记。在此网页上单击他的名字(“ Gullquist是首席投资官兼Lazard Asset Management的普通合伙人...”)后,它来自此网页:https://www.morningstar.com/funds/xnas/lziex/people
代码找不到那个家伙。是因为代码点击了错误的位置吗?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options)
driver.get("https://www.morningstar.com/funds/xnas/lziex/people")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='sal-component-ctn sal-component-manager-timeline-chart']//text[text()='Gullquist']/.."))).click()
print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.sal-modal-biography.ng-binding.ng-scope"))).text.strip())
此外,如果我希望每个人的履历(总共9个人)都来自Manager时间轴,而不是某个人?非常感谢您的帮助。
该行的xpath
值错误:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='sal-component-ctn sal-component-manager-timeline-chart']//text[text()='Gullquist']/.."))).click()
更改为以下值:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[text()='Herbert W. Gullquist']"))).click()