硒识别标签

时间:2018-07-10 17:29:27

标签: python-3.x selenium-webdriver

有什么想法如何在下面的标签中标识“ reservation.date”,以便使用Python Selenium提取日期为28/07/2018的日期?谢谢!

<td align="center" abbr="reservation.date"><div>Sat<br>28/07/2018 12:00</div> 
</td>

1 个答案:

答案 0 :(得分:-1)

您可以尝试 xpath

//td[@abbr='reservation.date']/descendant::br

Python代码:

date = driver.find_element_by_xpath("//td[@abbr='reservation.date']/descendant::br")  
print(date.text)

CSS选择器为:

td[abbr='reservation.date'] br

Python代码

date = driver.find_element_by_css_selector('td[abbr='reservation.date'] br')
print(date.text)

我不确定您是否要引入 WebDriverWait