Ejemplo n.º 1
0
        /// <summary>
        /// 返回请求数据
        /// </summary>
        /// <param name="curUrlObj"></param>
        /// <returns></returns>
        public SimpleCrawler.HttpResult GetHttpHtml(string url)
        {
            url = FixUrlSignStr(url);//修饰字符串
            // return GetPostDataFix(curUrlObj, accessToken);
            SimpleCrawler.HttpResult result = new SimpleCrawler.HttpResult();
            try
            {
                var item = new SimpleCrawler.HttpItem()
                {
                    URL    = url,
                    Method = "get",//URL     可选项 默认为Get
                    // ContentType = "text/html",//返回类型    可选项有默认值
                    UserAgent   = "okhttp/3.2.0",
                    ContentType = "application/x-www-form-urlencoded",
                };

                // item.Header.Add("Content-Type", "application/x-www-form-urlencoded");
                // hi.HeaderSet("Content-Length","154");
                // hi.HeaderSet("Connection","Keep-Alive");

                item.Header.Add("Accept-Encoding", "gzip");
                item.Header.Add("Authorization", curDeviceInfo.accessToken);
                item.Cookie = globalCookie;
                if (USEWEBPROXY)
                {
                    item.WebProxy = webProxy;
                }
                result = http.GetHtml(item);
            }
            catch (WebException ex)
            {
            }
            catch (TimeoutException ex)
            {
            }
            catch (Exception ex)
            {
            }
            return(result);
        }