到目前为止,我正在学习 C# 和它的乐趣,但我遇到了障碍。
我有一个程序可以在 Web 浏览器控件中抓取网页以获取信息。
到目前为止,我可以获得 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
您知道如何从当前网页获取链接列表以显示在文本框中吗?
谢谢克里斯。