我试图获取页面的源代码,但有些页面无法通过C#代码使用
获取源代码这是我的代码
private void button1_Click(object sender, EventArgs e)
{
using (var client = new WebClient())
{
string html = client.DownloadString("http://www.acusports.com/roster.aspx?roster=154&path=baseball");
html = textBox1.Text;
}
}
答案 0 :(得分:1)
切换以下语句时会发生什么:
html = textBox1.Text;
到此:
textBox1.Text = html;
在您的代码中,您将html
字符串设置为您检索的内容,然后立即使用textBox1.Text
的值覆盖它。
答案 1 :(得分:0)
你不想写:
textBox1.Text = html;