【问题标题】:how to get xpath of href title attribute如何获取href标题属性的xpath
【发布时间】:2020-06-16 20:11:32
【问题描述】:

如何提取这个的xpath(title="我想得到这个项目")

<div class="ads__item__actions">
<a href="https://www.xxx.html" title="I want to get this item" class="ads__item__ad--title" 
xpath="1">
some text</a>
</div>

【问题讨论】:

  • 我明白,但它位于哪里 - 在&lt;a&gt; 标签之前还是之后?
  • 在上面代码的末尾标记它
  • 标签: selenium selenium-webdriver xpath


    【解决方案1】:

    假设您的问题中有(更正的)html sn-p,那么

     titles = driver.find_elements_by_xpath('.//div/a')
     print(titles[0].get_attribute('title'))
    

    应该输出:

    I want to get this item
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-08
      • 1970-01-01
      • 2015-10-09
      • 2011-06-11
      • 2016-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多