Reputation: 557
I would like to retrieve the file url from a HTML meta-tag, given in the content
attribute.
Here is the example HTML code:
<meta content="https://www.domain.com/player/player-viral.swf?config=
https://www.domain.com/configxml?id=133291&logo.
link=http://www.domain.org/Amin+Rostami/-/Havam+Toei&
image=https://www.domain.com/img/3lv68bc5w-1396897306.jpeg&provider=audio&
file=http://s10.domain.me/music/A/[one]/test-msusic.mp3" property="og:video"/>
I would like to get the file url, in this case http://s10.domain.me/music/A/[one]/test-msusic.mp3
Upvotes: 1
Views: 251
Reputation: 473863
You can use substring-after()
to extract the link after the file=
from the content
attribute of a meta
tag:
substring-after(//meta/@content, "file=")
Demo (using xmllint
):
$ cat input.xml
<meta content="https://www.domain.com/player/player-viral.swf?config=
https://www.domain.com/configxml?id=133291&logo.
link=http://www.domain.org/Amin+Rostami/-/Havam+Toei&
image=https://www.domain.com/img/3lv68bc5w-1396897306.jpeg&provider=audio&
file=http://s10.domain.me/music/A/[one]/test-msusic.mp3" property="og:video"/>
$ $ xmllint input.xml --xpath 'substring-after(//meta/@content, "file=")'
http://s10.domain.me/music/A/[one]/test-msusic.mp3
Upvotes: 2