无法获取页面aspx网页的源代码

时间:2012-11-03 19:25:23

标签: c# web-crawler

我试图获取页面的源代码,但有些页面无法通过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;
        }
    }

2 个答案:

答案 0 :(得分:1)

切换以下语句时会发生什么:

html = textBox1.Text;

到此:

textBox1.Text = html;

在您的代码中,您将html字符串设置为您检索的内容,然后立即使用textBox1.Text的值覆盖它。

答案 1 :(得分:0)

你不想写:

textBox1.Text = html;