private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("In devolopment","Error", MessageBoxButtons.OK);
HtmlAgilityPack.HtmlWeb hw = new HtmlAgilityPack.HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = hw.Load("https://www.stackoverflow.com");
foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
{
usercon(link);
}
}
。
public void usercon(string toprint)
{
richTextBox1.Text += "\r\n";
richTextBox1.Text += toprint;
//richTextBox1.
}
我需要能够将link
转换为字符串,以便可以在函数usercon
中使用
这是我第一次使用HtmlAgilityPack
。
答案 0 :(得分:1)
根据此处的源代码:
https://htmlagilitypack.codeplex.com/SourceControl/latest#Release/1_4_0/HtmlAgilityPack/HtmlNode.cs
另见(新)文档:http://html-agility-pack.net/outer-html
HtmlNode在GitHub上有一个OuterHtml属性及其来源。
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("In devolopment","Error", MessageBoxButtons.OK);
HtmlAgilityPack.HtmlWeb hw = new HtmlAgilityPack.HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = hw.Load("https://www.stackoverflow.com");
foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
{
usercon(link.OuterHtml);
}
}