public static string UAGet(string url, string referer, string ck) { HttpWebRequest rq = (HttpWebRequest)WebRequest.Create(url); rq.Method = "GET"; SetHeaderValue(rq.Headers, "Connection", "keep-alive"); SetHeaderValue(rq.Headers, "Accept", "application/json, text/plain, */*"); //SetHeaderValue(rq.Headers, "X-Requested-With", "XMLHttpRequest"); SetHeaderValue(rq.Headers, "User-Agent", "jdapp;android;8.4.6;5.1.1;865166020162122-008135e7bee3;network/wifi;model/vivo y23l;addressid/0;aid/2d823f02aaf039a8;oaid/;osVer/22;appBuild/71541;psn/865166020162122-008135e7bee3|44;psq/80;uid/865166020162122-008135e7bee3;adk/;ads/;pap/JA2015_311210|8.4.6|ANDROID 5.1.1;osv/5.1.1;pv/40.81;jdv/;ref/com.jingdong.app.mall.home.JDHomeFragment;partner/jingdong;apprpd/Home_Main;Mozilla/5.0 (Linux; Android 5.1.1; vivo y23l Build/LMY49I; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.100 Mobile Safari/537.36"); SetHeaderValue(rq.Headers, "Referer", referer); SetHeaderValue(rq.Headers, "ContentType", "application/x-www-form-urlencoded; Charset=UTF-8"); SetHeaderValue(rq.Headers, "Cookie", ck); HttpWebResponse resp = null; try { resp = (HttpWebResponse)rq.GetResponse(); } catch (Exception) { Console.Write("远程服务被禁止了"); } using (Stream stream = resp.GetResponseStream()) { StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")); string responseString = reader.ReadToEnd(); return responseString; } }public static string UAPost(string url, string jdata, string cookie, string referer = null) { try { //data byte[] data = Encoding.UTF8.GetBytes(jdata); // Prepare web request... HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded; Charset=UTF-8"; request.Accept = "application/json, text/plain, */*"; request.UserAgent = "jdapp;android;8.4.6;5.1.1;865166020162122-008135e7bee3;network/wifi;model/vivo y23l;addressid/0;aid/2d823f02aaf039a8;oaid/;osVer/22;appBuild/71541;psn/865166020162122-008135e7bee3|44;psq/80;uid/865166020162122-008135e7bee3;adk/;ads/;pap/JA2015_311210|8.4.6|ANDROID 5.1.1;osv/5.1.1;pv/40.81;jdv/;ref/com.jingdong.app.mall.home.JDHomeFragment;partner/jingdong;apprpd/Home_Main;Mozilla/5.0 (Linux; Android 5.1.1; vivo y23l Build/LMY49I; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.100 Mobile Safari/537.36"; //request.Host = "www.xxx.com"; request.Headers.Add("Cookie", cookie); request.Referer = referer; request.ContentLength = data.Length; Stream newStream = request.GetRequestStream(); // Send the data. newStream.Write(data, 0, data.Length); newStream.Close(); // Get response HttpWebResponse myResponse = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); string content = reader.ReadToEnd(); return content; } catch (Exception) { throw; } }