public frmAuction() { InitializeComponent(); isLoged = false; auctionLog = new AuctionLog(false); orderPageHandle = new OrderPageHandle(auctionLog); orderPageHandleOld = new OrderPageHandleOld(auctionLog); orderPageHandleQuestion = new OrderPageHandleQuestion(auctionLog); productPageHandle = new ProductPageHandle(auctionLog); auctionOperations = new AuctionOperations(auctionLog); }
//获取验证码验证信息的方法 public string GetNewCheckCode(OrderPageHandle.CheckCode checkCode, CookieContainer ccEntered, out CookieCollection ccReturned) { if (string.IsNullOrEmpty(checkCode.J_checkCodeUrl)) { auctionLog.Log("警告:获取newCheckCode的URL地址为空"); ccReturned = new CookieCollection(); return string.Empty; } HttpWebRequest request; HttpWebResponse response; string queryString = "isCheckCode=" + checkCode.isCheckCode + "&" + "encrypterString=" + checkCode.encrypterString + "&" + "sid" + checkCode.sid + "&" + "gmtCreate" + checkCode.gmtCreate + "&" + "checkCodeIds" + checkCode.checkCodeIds + "&" + "checkCode=" + checkCode.checkCode; request = (HttpWebRequest)HttpWebRequest.Create(checkCode.J_checkCodeUrl + "?" + queryString); request.Method = "GET"; request.ProtocolVersion = HttpVersion.Version11; //request.Connection = "keep-alive"; request.ContentType = " application/x-www-form-urlencoded; charset=UTF-8"; request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.861.0 Safari/535.2"; request.Accept = "*/*"; request.Referer = "http://buy.taobao.com/auction/buy_now.jhtml"; //request.Headers.Add("Connection", "keep-alive"); request.Headers.Add("X-Requested-With", "XMLHttpRequest"); request.Headers.Add("Accept-Encoding", "gzip,deflate,sdch"); request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8"); request.Headers.Add("Accept-Charset", "GBK,utf-8;q=0.7,*;q=0.3"); request.CookieContainer = ccEntered; request.AllowAutoRedirect = true; response = (HttpWebResponse)request.GetResponse(); ccReturned = response.Cookies; Stream st; st = response.GetResponseStream(); if (response.ContentEncoding.ToLower().Contains("gzip")) { st = new GZipStream(st, CompressionMode.Decompress, true); } string htmlText = string.Empty; StreamReader stReader = new StreamReader(st, Encoding.GetEncoding("gb2312")); htmlText = stReader.ReadToEnd(); stReader.Close(); st.Close(); auctionLog.ShowTextInForm(response.ResponseUri.ToString(), htmlText); response.Close(); return htmlText; }