python - Selenium 将数据解析为变量

标签 python variables selenium selenium-webdriver

Selenium 是否可以解析源代码并找到“上次更新”的特定文本,然后将包含日期和时间的整行复制到变量中?

HTML - 复制到变量中的代码

Last updated: <strong>31.12.2015 17.46</strong>

最佳答案

找到具有此特定 preceding text siblingstrong 元素:

driver.find_element_by_xpath("//strong[contains(preceding-sibling::text(), 'Last updated: ')]").text

关于python - Selenium 将数据解析为变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34557865/

相关文章:

python - 为什么 namedtuple 模块不使用元类来创建 nt 类对象?

python - 将零移动到末尾 : Why does my Python Code fail the test in CodeWars?

java - 私有(private)变量是否与私有(private)类中的包/默认/无修饰符变量具有相同的访问权限?

python - Selenium + ChromeDriver printToPDF

python - ElementClickInterceptedException : Message: element click intercepted: Element <label> is not clickable with Selenium and Python

python - Pandas 将多个列分组为集合并对其他列进行排序

Python - 从字典列表中删除重复键

python - 在打印功能中包含变量的问题

vba - 为什么 VBA dim 语句根据声明的变量数量而表现不同?

c# - IE Web 驱动程序在 TeamCity Windows Server 2012 上运行速度慢 3-5 倍