| 本帖最后由 yi_shu 于 2015-12-17 10:22 编辑 
 第一次提交用户名密码后获取的 cookie好像是正确的,但是第二次提交的时候,却不能返回正常页面,而是空白页,why?
 
 [C#] 纯文本查看 复制代码 private void WorkJisilu()
        {
            HttpHelper httpPost = new HttpHelper();
            HttpItem itempost = new HttpItem
            {
                URL = "http://www.jisilu.cn/account/ajax/login_process/",
                Method = "post",
                Host = "www.jisilu.cn",
                Accept = "application/json, text/javascript, */*; q=0.01",
                UserAgent = " Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 BIDUBrowser/8.1 Safari/537.36",
                ContentType = "application/x-www-form-urlencoded; charset=UTF-8",
                Referer="http://www.jisilu.cn/login/",
                Postdata = "return_url=http%3A%2F%2Fwww.jisilu.cn%2F&user_name=[color=red]username[/color]&password=[color=red]userpass[/color]&net_auto_login=1&_post_type=ajax",
            };
//上面红字改为自己的用户名和密码
            HttpResult resultPost = httpPost.GetHtml(itempost);
            string htmlPost = resultPost.Html;
            string cookies = resultPost.Cookie;
            
            richTextBox1.Text = cookies;          
            string url = "http://www.jisilu.cn/data/sfnew/arbitrage_vip_list/?___t=";
            url = url + ConvertDateTimeToInt(DateTime.Now).ToString();
            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = url,
                Cookie = cookies,
                Method = "get",               
            };
            HttpResult result = http.GetHtml(item);
            string html = result.Html;                    
            richTextBox1.Text += html;          
        }
       
        /// <summary>  
        /// 将c# DateTime时间格式转换为Unix时间戳格式  
        /// </summary>  
        /// <param name="time">时间</param>  
        /// <returns>long</returns>  
        public static long ConvertDateTimeToInt(System.DateTime time)
        {
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
            long t = (time.Ticks - startTime.Ticks) / 10000;   //除10000调整为13位      
            return t;
        }
 |