【发布时间】:2013-11-24 21:07:20
【问题描述】:
我正在尝试这段代码:
private void htmlparsing(string htmlfile)
{
List<string> test = new List<string>();
HtmlDocument doc = new HtmlDocument();
doc.Load(htmlfile);
foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
{
HtmlAttribute att = link.Attributes["href"];
test.Add(att.Value);
}
doc.Save(@"d:\file.htm");
}
这是我正在处理的 html 文件:https://skydrive.live.com/redir?resid=EB1C71C44C3976D5!318&authkey=!AKxxwSboig3BQpo
当我使用断点并在工作完成后观看列表测试时,我看到 154 个链接,但我没有看到例如 html 文件内容中的链接:
"http://www.niederschlagsradar.de/images.aspx?jaar=-6&type=europa.cld&datum=201311151500&cultuur=en-GB&continent=europa","http://www.niederschlagsradar.de/images.aspx?jaar=-6&type=europa.cld&datum=201311151800&cultuur=en-GB&continent=europa"
有很多链接有61-62个链接,我在列表测试中没有看到这个链接。
第二个链接在:
var images = new Array(
最后
);
所以第一步我想从 html 文件中获取所有 http 链接。 其次,我想过滤并从 html 文件中获取所有 http 链接: var images = new Array( 和 );
【问题讨论】:
-
隔离问题。仅使用相关的 HTML 对其进行测试,将 URL 替换为
http://example.com并在此处显示 HTML。
标签: c# html-agility-pack