我有一个HTML文件,其中有许多行,如下所示:
<a href="/n/lastname" class="profimg">
<img src="http://images.nosite.com/profiles/profile_183140203_75sq_1393790252.jpg" alt="" width="72" height="72">
</a>
我需要提取href和src标记信息。我下载了htmlagilitypack,它似乎简化了过程,但现在我可以得到一个或另一个。我怎样才能得到这两个?感谢。
答案 0 :(得分:-1)
这个怎么样,您可以使用jquery Child Selector来引用img
标记中提供的<a>
var href = $(".profimg").attr('href');
var src = $(".profimg > img").attr("src");
alert(href); // /n/lastname
alert(src); // http://images.nosite.com/profiles/profile_183140203_75sq_1393790252.jpg