for  (int  i=300;i<=500;i++)  
{  
string  StrUrl="http://www.*.com/read.asp?id="+i.ToString()+"";  
System.Object  MyObject="";  
this.axWebBrowser1.Navigate(StrUrl,ref  MyObject,ref  MyObject,ref  MyObject,ref  MyObject);  
mshtml.HTMLDocumentClass  doc  =(mshtml.HTMLDocumentClass)axWebBrowser1.Document;  
IHTMLDocument2  HTMLDocument  =  (IHTMLDocument2)  axWebBrowser1.Document;    
string  source=HTMLDocument.body.outerHTML;  
string  pathd="read.txt";  
FileStream  sb=new  FileStream(pathd,FileMode.Append,FileAccess.Write);  
StreamWriter  sw=new  StreamWriter(sb);  
sw.Write(source+"\r\n");  
sw.Close();  
}  
 
为什么取到的html代码只有http://www.*.com/i.asp?id=300这一个页面的源代码  
取循环下去的url都没取到代码    
是怎么回事啊`  
我看了下循环是执行了  
但好象axWebBrowser没有去访问那么多web页    是怎么回事呢

解决方案 »

  1.   

    获得页面的源代码推荐用
    http://community.csdn.net/Expert/TopicView.asp?id=4066881
    中的HttpWebRequest的方法,
    axWebBrowser还会下在图片等,不如上面的方法好
      

  2.   

    用HttpWebRequest没办法获取不允许匿名访问的url(在知道登陆帐号和密码的情况下)
    而axWebBrowser能~
      

  3.   

    NO!
    可以用HttpWebRequest.Credentials来实现身份验证
      

  4.   

    http://community.csdn.net/Expert/TopicView.asp?id=4066881
      

  5.   

    你先参考一下MSDN吧
    http://msdn.microsoft.com/library/CHS/cpref/html/frlrfSystemNetHttpWebRequestClassCredentialsTopic.asp
    还有我前面给的那个帖子
    我现在没空调试
      

  6.   

    搞定了  谢了  结帖  
    想和fancyf(凡瑞)交个朋友 不知道可否告知MSN或QQ
      

  7.   

    for (int i=1; i<10000; i++)
    {
    Console.WriteLine("{0:d5}", i);
    }
      

  8.   

    天啊  转换到winfrom下 是什么格式
      

  9.   

    label.Text = string.Format("{0:d5}", i);