出现问题: 
  asp.net模拟登陆需要采集的指定页面后(假设为:member/index.aspx)采集不到数据(获取的数据内容老是为:You are not currently connected to the website),从网站登录进去member/index.aspx后再去采集则可以获取想要的Code, 
附:登录后刚加载member/index.aspx页面输出的内容是:You are not currently connected to the website,几秒后才开始显示我想要的Code; 

解决方案 »

  1.   

    如果登录后直接打开member/index.aspx页面,该页面加载数据时显示的内容为You are not currently connected to the website,加载完数据后显示的数据才是我想采集的Code,但我采集的话老是采集不到我想要的Code,而采集的老是You are not currently connected to the website这句;再有就是如果我先登录member/index.aspx后再调试程序,此时可以得到想要的Code,如说得还不清楚,麻烦加我QQ:286730272  这里不好发图片,小弟先谢了
      

  2.   

    延迟调用不行,我有考虑过如果采集的不是想要的Code,循环继续采集,但还是采集不到;也试了先模拟登录再加定时器采集也采集不到,(备:这里第一次后的每次采集过程都再只登录一次的前提下执行的,也就是说第一次登陆后,后面采集再不用执行这个登录方法了)
      

  3.   

    当前不能连接网站
    private string HttpWebRequestLogin(string loginUrl, string postData, ref CookieContainer cookieContainer)
    {
        byte[] bdata = Encoding.Default.GetBytes(postData);
        System.Net.HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(loginUrl);
        myRequest.Method = "POST";
        myRequest.ContentType = "application/x-www-form-urlencoded";
        myRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
        myRequest.Referer = loginUrl;
        myRequest.KeepAlive = true;
        myRequest.AllowAutoRedirect = true;
        if (cookieContainer == null)
            cookieContainer = new CookieContainer();
        myRequest.CookieContainer = cookieContainer;
        myRequest.ContentLength = bdata.Length;
        Stream newStream = myRequest.GetRequestStream();
        newStream.Write(l_data, 0, bdata.Length);
        newStream.Close();
        HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
        StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("GB2312"));
        string content = reader.ReadToEnd();
        return content;
    }
    先要登录网站,再采集数据。每次采集,通过Thread实现延迟
      

  4.   

    有用Thread延时调用但还是获取不到
        void bind()
        {
            string url = "http://live.arbitragepro.com/modules/arb/index.php";
            CookieContainer myCookieContainer = cc;
            string referer = "";
        
            string l_ret = "";
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            myHttpWebRequest.ContentType = "text/html";
            myHttpWebRequest.Method = "GET";
            myHttpWebRequest.Referer = referer;
            //myHttpWebRequest.Headers.Add("cookie:" + cookieHeader);
            myHttpWebRequest.CookieContainer = myCookieContainer;        HttpWebResponse response = null;
            System.IO.StreamReader sr = null;
            Thread.Sleep(20000);
            response = (HttpWebResponse)myHttpWebRequest.GetResponse();
            sr = new System.IO.StreamReader(response.GetResponseStream(), Encoding.GetEncoding("gb2312"));    //    //utf-8
            l_ret = sr.ReadToEnd();
         //   string s = null;
        }