Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xpath html敏捷包提取背景图像_Xpath_Html Agility Pack - Fatal编程技术网

Xpath html敏捷包提取背景图像

Xpath html敏捷包提取背景图像,xpath,html-agility-pack,Xpath,Html Agility Pack,如何从以下HTML中提取url i、 摘录: http://media.somesite.com.au/img-101x76.jpg 发件人: 一般来说,在XPath1.0中,可以组合使用substring after和substring before函数来提取部分文本。但是HAP的SelectNodes和SelectSingleNode只能返回节点,所以这些XPath函数没有帮助 一种可能的方法是使用XPath和HAP获取style属性的整个值,然后使用regex进一步处理.NET中的值,例

如何从以下HTML中提取url

i、 摘录:

http://media.somesite.com.au/img-101x76.jpg
发件人:


一般来说,在XPath1.0中,可以组合使用substring after和substring before函数来提取部分文本。但是HAP的SelectNodes和SelectSingleNode只能返回节点,所以这些XPath函数没有帮助

一种可能的方法是使用XPath和HAP获取style属性的整个值,然后使用regex进一步处理.NET中的值,例如:

变量html=@ ; var doc=新的HtmlDocument; doc.LoadHtmlhtml; var div=doc.DocumentNode.SelectSingleNode//div[contains@class,'searched-img'];
var url=Regex.Matchdiv.GetAttributeValuestyle,@?嘿,干得好!没有正则表达式,我什么也得不到。这一切都有点令人困惑。谢谢
<div class="media-img">
    <div class=" searched-img" style="background-image: url(http://media.somesite.com.au/img-101x76.jpg);"></div>
</div>
http://media.somesite.com.au/img-101x76.jpg