Xpath html敏捷包提取背景图像
如何从以下HTML中提取url i、 摘录: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中的值,例
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