Xpath:从<div>

2024-09-28 03:22:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下源代码:

<div class = "price-text--price-part--Tu6MH udlite-clp-discount-price udlite-heading-xxl" data-purpose = "course-price-text">
     <span class = "udlite-sr-only"> Current Price </span>
     <span>
           <span> 47.99 </span>
     </span>
</div>

现在我想得到一个结果:47.99使用xpath。我该怎么做


Tags: textdivdata源代码discountpriceclassspan
1条回答
网友
1楼 · 发布于 2024-09-28 03:22:24
driver.find_element_by_xpath('//div/span[2]/span').text

专业提示:要在网站上查找元素的XPath,您可以使用inspect元素,右键单击要使用XPath的元素,选择copy,然后选择copy XPath

相关问题 更多 >

    热门问题