XPath for text following other text?

I am a beginner in python. Sorry for this easy question, but I just cannot get the value. How can I get the number "10655140"?

<HEAD> <BASE target="_top"> <TITLE>United States Patent: 10655140</TITLE></HEAD> 

My code is below which doesn’t work.

html.xpath('//HEAD[contains(text(),"United States Patent")]//TITLE/text()') 
Add Comment
1 Answer(s)

This XPath,

substring-after(/HEAD/TITLE, "United States Patent: ") 

will select the substring after "United States Patent: " in the string value of the TITLE child of the HEAD root element, as requested:

10655140 

Note that the BASE open tag is not closed in your markup.

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.