/// <summary> /// 获取请求返回的html字符串 /// </summary> /// <param name="url"></param> /// <returns></returns> public static string GetHtmlStr(string url) { try { string aaa = "{%22id%22:121%2C%22name%22:%22lijun%22%2C%22mobile%22:%2218516063170%22%2C%22roleName%22:%22%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98%22%2C%22permission%22:%221000%2C2000%2C3000%2C4000%2C5000%2C6000%2C7000%2C8000%2C4010%22%2C%22roleId%22:1}"; 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 Cookie: sc_is_visitor_unique=rx2315234.1588770685.05827513433E4F5F5A2A1E1D48145FCA.4.3.3.3.3.3.2.2.2 Host: www.h528.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/79.0.3945.88 Safari/537.36"; HttpRequestClient sc = new HttpRequestClient(true); var response = sc.httpGet(url, heads); return(response); } catch (WebException ex) { //连接失败 return(null); } }
/// <summary> /// 获取请求返回的html字符串 /// </summary> /// <param name="url"></param> /// <returns></returns> public static string GetHtmlStr(string url) { try { 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 Connection: keep-alive Cookie: UM_distinctid=165a2838a2c1b-0a85a6219240a8-9393265-1fa400-165a2838a2d4; CNZZDATA1273963295=1563960200-1536024787-%7C1536044894 Host: www.rail-transit.com Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"; HttpRequestClient sc = new HttpRequestClient(true); //var response = sc.httpPost(url, heads, "", Encoding.UTF8); var response = sc.httpGet(url, heads, ""); return(response); } catch (WebException ex) { //连接失败 return(null); } }
public static string GetDetailStr(string shopid) { try { string url = string.Format("http://m.dianping.com/shop/{0}", shopid); 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 Connection: keep-alive Cookie: _lxsdk_cuid=162dcf84af9c8-034273fca8ff5d-b34356b-1fa400-162dcf84af9c8; _lxsdk=162dcf84af9c8-034273fca8ff5d-b34356b-1fa400-162dcf84af9c8; _hc.v=''8a8af4af-d518-45d4-bce6-e312f757ab5a.1524125682\""; cye=shenzhen; s_ViewType=10; aburl=1; _lx_utm=utm_source%3DBaidu%26utm_medium%3Dorganic; cy=7; cityid=7; msource=default; default_ab=shop%3AA%3A1; _lxsdk_s=165565c39fa-54b-b47-3c9%7C%7C73 Host: m.dianping.com Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"; HttpRequestClient sc = new HttpRequestClient(true); var response = sc.httpGet(url, heads); return(response); } catch (WebException ex) { //连接失败 return(null); } }
/// <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); } }
/// <summary> /// 获取请求返回的html字符串 /// </summary> /// <param name="url"></param> /// <returns></returns> public static string GetHtmlStr(string url) { try { string aaa = "{%22id%22:121%2C%22name%22:%22lijun%22%2C%22mobile%22:%2218516063170%22%2C%22roleName%22:%22%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98%22%2C%22permission%22:%221000%2C2000%2C3000%2C4000%2C5000%2C6000%2C7000%2C8000%2C4010%22%2C%22roleId%22:1}"; 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); var response = sc.httpGet(url, heads); return(response); } catch (WebException ex) { //连接失败 return(null); } }
/// <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); } }