Z
Z
zilevsky2022-03-01 23:32:39
css
zilevsky, 2022-03-01 23:32:39

How to get a number from a string using xpath?

Good afternoon.
How to get a number from a string using xpath?
<td><div>ИНН: 0123456789</div></td>

Now I'm looking like this, but in the end I get the whole line and I have to apply another regular expression to clean it up.
tree.xpath("//td/div/text()")

Can eat a variant to apply in xpath the regular expression?
I did not find anything suitable in the manual. Or, I'm using it wrong.
https://devhints.io/xpath

Answer the question

In order to leave comments, you need to log in

6 answer(s)
E
Eduards Vigulis, 2016-04-15
@trenrnd

Maybe something like that ?
Not the cleanest code, and most likely not the most correct option, but this is the first thing that came to mind...

A
Andrew Tantalid, 2016-04-15
@Tantalid

Corners use before and after pseudo elements that are absolutely positioned. The .box__cont element is needed to overlap elements with an absolute and to decorate the text.
https://jsfiddle.net/2fa29uw8/

A
A person from Kazakhstan, 2016-04-15
@LenovoId

https://cloud.mail.ru/public/H1mJ/RNt4ibAVP here is a link to the layout and a screen attached - the path in the address bar of the browser I think you will not deceiveff7c5f1d307f49b98afd7b0874d815f5.png

A
Alexander, 2016-04-15
@Palehin

As an option codepen.io/anon/pen/KzojNW
PS but I would make up pictures :)

E
Electro House, 2022-03-03
@laim731

If it's on a website page, in the PCM debugger, copy the xpath

Z
Zolg, 2022-03-02
@Zolg

<td><div>ИНН: 0123456789</div></td>
If you parse exactly html, then I highly recommend to score on xpath and use Beautiful Soup and CSS selectors. The ability to match, including regular expressions, is just one of many nice goodies
. If it’s still important to use xpath and native regular expressions for it, then lxml can do this, but the syntax is not very sugary

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question