[英]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.