HTML敏捷性包帮助 [英] Html Agility Pack help
问题描述
我想刮从网站的一些信息,但无法找到适合我的解决方案。我在互联网上阅读每个代码生成至少一个错误给我。
I'm trying to scrape some information from a website but can't find a solution that works for me. Every code I read on the Internet generates at least one error for me.
即使在其主页上的示例代码为我生成错误。
Even the example code at their homepage generates errors for me.
我的代码:
HtmlDocument doc = new HtmlDocument();
doc.Load("https://www.flashback.org/u479804");
foreach(HtmlNode link in doc.DocumentElement.SelectNodes("//a[@href"])
{
HtmlAttribute att = link["href"];
att.Value = FixLink(att);
}
doc.Save("file.htm");
生成以下错误:
的HTMLDocument'是'System.Windows.Forms.HtmlDocument'和'HtmlAgilityPack.HtmlDocument'C之间不明确的引用* \Form1.cs
'HtmlDocument' is an ambiguous reference between 'System.Windows.Forms.HtmlDocument' and 'HtmlAgilityPack.HtmlDocument' C:*\Form1.cs
编辑:我的整个代码位于此处的 http://beta.yapaste.com/55
My entire code is located here: http://beta.yapaste.com/55
所有帮助非常感谢!
推荐答案
使用 HtmlAgilityPack.HtmlDocument
:
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
编译器感到困惑,因为你们两个已经带有使用导入的命名空间
含有类名为的HTMLDocument
的 - 在HTML敏捷性包命名空间,Windows窗体命名空间。您可以通过指定要明确使用哪一个类解决这个问题。
The compiler is getting confused because two of the namespaces you have imported with using
contain classes called HtmlDocument
- the HTML Agility Pack namespace, and the Windows Forms namespace. You can get around this by specifying which class you want to use explicitly.
这篇关于HTML敏捷性包帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!