C#我可以在webBrowser控件上搜索链接吗?

C#我可以在webBrowser控件上搜索链接吗?,c#,richtextbox,hyperlink,scrape,C#,Richtextbox,Hyperlink,Scrape,到目前为止,我正在学习C#及其乐趣,但我遇到了一个障碍 我有一个程序,可以刮网页内的网页浏览器控件的信息 到目前为止,我可以得到HTML HtmlWindow window = webBrowser1.Document.Window; string str = window.Document.Body.OuterHtml; richTextBox1.Text = (str.ToString()); 和文本 HtmlWindow window = webBrowser1.Document.

到目前为止,我正在学习C#及其乐趣,但我遇到了一个障碍

我有一个程序,可以刮网页内的网页浏览器控件的信息

到目前为止,我可以得到HTML

HtmlWindow window = webBrowser1.Document.Window;
string str = window.Document.Body.OuterHtml;
richTextBox1.Text = (str.ToString());   
和文本

HtmlWindow window = webBrowser1.Document.Window;
string str = window.Document.Body.OuterText;
richTextBox1.Text = (str.ToString());
我曾经尝试过这样的链接

HtmlWindow window = webBrowser1.Document.Window;
string str = window.Document.Body.GetElementsByTagName("A").ToString();
richTextBox1.Text = str;
但是,表单上的富文本框将填充以下内容

System.Windows.Forms.HtmlElementCollection
你知道如何从当前网页中获取链接列表以显示在文本框中吗

谢谢
克里斯。

有了HtmlAgility软件包,您可以轻松:

HtmlWindow window = webBrowser1.Document.Window;
string str = window.Document.Body.OuterHtml;

HtmlAgilityPack.HtmlDocument HtmlDoc = new HtmlAgilityPack.HtmlDocument();
HtmlDoc.LoadHtml(str);

HtmlAgilityPack.HtmlNodeCollection Nodes = HtmlDoc.DocumentNode.SelectNodes("//a");

foreach (HtmlAgilityPack.HtmlNode Node in Nodes)
{
    textBox1.Text += Node.OuterHtml + "\r\n";
}