Reputation:
What xpath should i use to extract only the url link from the below element?
<a class="url" rel="noreferrer" onclick="redirect('https://www.fotbollskanalen.se/allsvenskan/kujovic-siktar-pa-startplats-var-naturligt-att-agera-inhoppare---nu-vill-jag-s');">Läs mer på Fotbollskanalen</a>
I have tried using the below xpath, but it only returns "Läs mer på Fotbollskanalen" and not the url itself.
a[1]/child::node()
Also tried different versions attempting to set specify the class but unable to get it right.
Upvotes: 2
Views: 60
Reputation: 8124
Try this:
substring-before(substring-after(//a/@onclick, "'"),"'")
It will,
substring-before(substring-after(foo, "'"),"'")
:
Get in everything enclosed by '
in foo
.//a
: Of the element a./@onclick
: Inside the attribute onclick
.Upvotes: 1