获取的HTML网页上的所有链接? [英] Get all links on html page?
本文介绍了获取的HTML网页上的所有链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
林工作的一个小爱好的项目。我已经写了code得到一个网址,下载头和返回MIME类型/内容类型。
Im working on a little hobby project. I already have written the code to get a url, download the header and return the mime type / content type.
不过,在此之前的一步是一个IM卡在 - 我需要找回基于标记内页上的所有URL的内容,并在引号即
However, the step before this is the one im stuck on - i need to retrieve the contents of all the urls on the page based inside a tag, and in quotes i.e.
...
<link rel='shortcut icon' href="/static/favicon.ico" type="image/x-icon" />
...
会发现图标的链接。
Would find the favicon link.
有什么有用的.NET库或此将不得不对正则表达式的情况?
Is there anything helpful in the .net library or is this going to have to be a case for regex?
推荐答案
我想看看使用 HTML敏捷性包。
下面是一个例子直接从他们的榜样页面上如何找到一个网页所有链接:
Here's an example straight from their examples page on how to find all the links in a page:
HtmlWeb hw = new HtmlWeb();
HtmlDocument doc = hw.Load(/* url */);
foreach(HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
{
}
这篇关于获取的HTML网页上的所有链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文