为什么elems.Count.ToString()总是0
private void button1_Click(object sender, EventArgs e){
string result = null;
string url = "http://www.baidu.com/";
WebResponse response = null;
StreamReader reader = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
response = request.GetResponse();
reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
result = reader.ReadToEnd();
WebBrowser b = new WebBrowser();
b.DocumentText = result;
HtmlDocument doc = b.Document;
HtmlElementCollection elems = null;
if (doc != null)
{
elems = doc.GetElementsByTagName("a");
textBox1.Text = elems.Count.ToString();//为什么运行结果总是0
}
}