Пример #1
0
        /// <summary>
        /// 获取请求返回的html字符串
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string GetHtmlStr(string url)
        {
            try
            {
                //GetToken("http://www.dianping.com");

                string heads = @"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: max-age=0
Cookie: showNav=#nav-tab|0|2; navCtgScroll=100; _lxsdk_cuid=162dcf84af9c8-034273fca8ff5d-b34356b-1fa400-162dcf84af9c8; _lxsdk=162dcf84af9c8-034273fca8ff5d-b34356b-1fa400-162dcf84af9c8; _hc.v=''8a8af4af-d518-45d4-bce6-e312f757ab5a.1524125682'';cy=7; cye=shenzhen; s_ViewType=10; aburl=1; _lx_utm=utm_source%3DBaidu%26utm_medium%3Dorganic; _lxsdk_s=165455e68c1-fd6-46c-d56%7C%7C1408
Host: www.dianping.com
Proxy-Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";


                HttpRequestClient sc = new HttpRequestClient(true);
                var response         = sc.httpPost(url, heads, "", Encoding.UTF8);
                return(response);
            }
            catch (WebException ex)
            {
                //连接失败
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 获取请求返回的html字符串
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string PostHtmlStr(string url, int pageIndex = 1)
        {
            try
            {
                //GetToken("http://www.dianping.com");

                string heads = $@"Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: keep-alive
Content-Length: 62
Content-Type: application/x-www-form-urlencoded
Host: 175.24.134.140:3000
Origin: http://175.24.134.140:9092
Referer: http://175.24.134.140:9092/home?page=1&limit=200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36";

                //                string heads = $@"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
                //Accept-Encoding: gzip, deflate
                //Accept-Language: zh-CN,zh;q=0.9
                //Cache-Control: max-age=0
                //Connection: keep-alive
                //Cookie: token=686423fd8acc14fecc03466ffc94fb2c06e9236e; user={aaa}; access=1000%2C2000%2C3000%2C4000%2C5000%2C6000%2C7000%2C8000%2C4010; shrink=; bookIds=314; huyan=true; light=true; fontSize=small
                //Host: 175.24.134.140:1111
                //Upgrade-Insecure-Requests: 1
                //User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36";


                HttpRequestClient sc = new HttpRequestClient(true);

                string content = $"page={pageIndex}&limit=200&token=686423fd8acc14fecc03466ffc94fb2c06e9236e";

                var response = sc.httpPost(url, heads, content, Encoding.UTF8);
                return(response);
            }
            catch (WebException ex)
            {
                //连接失败
                return(null);
            }
        }