xPath从标记样式中获取值

时间:2017-09-27 11:49:49

标签: html xpath

HTML代码:

<style type="text/css">
    body {background-image: url(https://www.example.org/image.jpg)};
</style>

我是否可以使用xPath获取图像链接? ©google-tranlate
如果可能请帮助。

1 个答案:

答案 0 :(得分:0)

是的,您可以通过下一个XPath获取您的网址:

translate(substring-after(//style/text(),"url"),')(};',' ')

在此:

您可以从标签“STYLE”获取文字://style/text()

然后你从url substring-after(//style/text(),"url")

获得子串

在最后的格式中,这是子字符串,更改空格上的特殊符号,例如)(}; translate('your_substing','have_your_special_symbols','and_change_its_on_free_space')

相关问题