示例#1
0
        private void SendRequest(HttpWebRequest request, DealWithResponse dealwithCB, object dealwithPar)
        {
            RequestState state = new RequestState();

            state.request     = request;
            state.dealwithfun = dealwithCB;
            state.dealwithpar = dealwithPar;
            state.buffer      = new MemoryStream();
            state.tmpBuf      = new byte[1024];
            request.Headers.Add(HttpRequestHeader.CacheControl, "max-age=0");
            request.Accept    = "text/html,application/xhtml+xml;q=0.9,image/webp,*/*;q=0.8";
            request.UserAgent = "Mozilla/5.0(window NT 6.1) Applewebkit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 safari/537.36";
            //request.Headers.Add(HttpRequestHeader.Accept, "text/html,application/xhtml+xml;q=0.9,image/webp,*/*;q=0.8");
            //request.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0(window NT 6.1) Applewebkit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 safari/537.36");
            request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate,sdch");
            request.Headers.Add(HttpRequestHeader.AcceptLanguage, "zh-cn,zh;q=0.8");
            //request.CookieContainer = new CookieContainer();
            //request.CookieContainer.Add(new Cookie("__test", "11"));
            //request.CookieContainer.Add(new Cookie("x__utmvc", "1"));
            //request.CookieContainer.Add(new Cookie("PHPSESSID", "7b9d72107ad3af399e964a2442dac7d9"));
            //request.CookieContainer.Add(new Cookie("visid_incap_146743", "V8w1iWmWQk2aN23QPhVdmwm6yVMAAAAAQUIPAAAAAAAap46eSzXwuSOLQTnA+QWR"));
            //request.CookieContainer.Add(new Cookie("incap_ses_200_146743", "z9uNSToNaykTAJvzOIvGAudr81MAAAAAE2ZWW3YIC/vbCTJw7mE+YA=="));
            //request.CookieContainer.Add(new Cookie("__utma", "124867215.161693485.1404718479.1408459005.1408461452.16"));
            //request.CookieContainer.Add(new Cookie("__utmz", "124867215.1404718479.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)"));
            //request.CookieContainer.Add(new Cookie("__atuvc", "49%7C30%2C10%7C31%2C43%7C32%2C11%7C33%2C10%7C34"));

            request.BeginGetResponse(new AsyncCallback(RespCallback), state);
        }
示例#2
0
        public void Open(string url, DealWithResponse dealwithFun, object dealwithPar)
        {
            HttpWebRequest   request        = (HttpWebRequest)(WebRequest.Create(url));
            DealWithResponse dealwithSearch = new DealWithResponse(dealwithFun);

            SendRequest(request, dealwithSearch, dealwithPar);
        }