有人能理解这段代码的问题是什么吗?我知道这个问题并不新鲜,但我所发现的并没有帮助我,但也许我看上去很糟糕。
wd = webdriver.Chrome('chromedriver',options=chrome_options)
wd.get('https://www.uniprot.org/uniprotkb/Q14050/entry')
sleep(15)
Molmass = wd.find_element('xpath','//*[@id="sequences"]/div/div[2]/section/ul/li[2]/div/div[2]')HTML:
<div class="decorated-list-item__content">63,616</div>选择器:
#sequences > div > div.card__content > section > ul > li:nth-child(2) > div > div.decorated-list-item__contentXPATH:
//*[@id="sequences"]/div/div[2]/section/ul/li[2]/div/div[2]错误:
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="sequences"]/div/div[2]/section/ul/li[2]/div/div[2]"}
(Session info: headless chrome=107.0.5304.87)我尝试按类、选择器、xpath进行搜索,但是没有任何帮助,我试图设置一个计时器,以便页面有时间加载,但是没有结果。
发布于 2022-11-23 02:25:27
我假设您正在尝试获取'63,616‘值,因为您可以使用以下任何一个定位器:
CSS_SELECTOR:
driver.find_element(By.CSS_SELECTOR, ".sequence-container li:nth-of-type(2) .decorated-list-item__content").textXPATH:
driver.find_element(By.XPATH, ".//section[@class='sequence-container']//li[2]//div[@class='decorated-list-item__content']").texthttps://stackoverflow.com/questions/74538790
复制相似问题