Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have the following source code:

<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>

Now I want to get as a result: 47.99 using xpath. How Can I do that ?

question from:https://stackoverflow.com/questions/65907451/xpath-select-content-from-a-specific-span-inside-an-div

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
312 views
Welcome To Ask or Share your Answers For Others

1 Answer

driver.find_element_by_xpath('//div/span[2]/span').text

Pro tip: to find the XPath of an element on a website you can use inspect element, right click the element you want the XPath for, select copy, then copy XPath.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...