[英]Python Selenium find element (title) in a specific date
我正在使用 Selenium 来取回在特定日期发布的一些文章
我试过了:
driver.get('https://www.globalcapital.com/Asia/Bonds/Corp')
while True:
links=[link.get_attribute('href') for link in driver.find_elements_by_xpath("//div[contains(@title,'01 Feb 2021')/preceding::a[2]")]
for link in links:
# I want to return all href first to a csv
# and then return to the title of the article
但是'不是一个有效的 XPath 表达式',我在这里有两个问题:
提前致谢!
它无效,因为您忘记了右方括号。 尝试
"//div[contains(@title,'01 Feb 2021')]/preceding::a[2]"
不, preceding
/ following
不仅用于兄弟姐妹。 preceding-sibling
/ following-sibling
仅用于兄弟姐妹
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.