public static string GetDataByKuaidi100(string computer, string expressNo, int show = 0) { string text = "29833628d495d7a5"; string value = ""; string text2 = null; string text3 = "暂时没有此快递单号的信息"; HttpContext current = HttpContext.Current; if (current != null) { text2 = current.Request.MapPath("~/Express.xml"); } XmlDocument xmlDocument = new XmlDocument(); if (!string.IsNullOrEmpty(text2)) { xmlDocument.Load(text2); XmlNode xmlNode = xmlDocument.SelectSingleNode("companys"); if (xmlNode != null) { string value2 = xmlNode.Attributes["Kuaidi100NewKey"].Value; if (!string.IsNullOrEmpty(value2)) { value = value2; } } } string result; if (string.IsNullOrEmpty(value)) { string expressCode = Express.GetExpressCode(computer); string requestUriString = string.Concat(new string[] { "http://api.kuaidi100.com/api?id=", text, "&com=", expressCode, "&nu=", expressNo, "&show=0&muti=1&order=asc" }); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUriString); httpWebRequest.Timeout = 8000; HttpWebResponse httpWebResponse; try { httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); } catch { result = text3; return(result); } if (httpWebResponse.StatusCode == HttpStatusCode.OK) { Stream responseStream = httpWebResponse.GetResponseStream(); StreamReader streamReader = new StreamReader(responseStream, Encoding.GetEncoding("UTF-8")); text3 = streamReader.ReadToEnd(); text3 = text3.Replace("&", ""); text3 = text3.Replace(" ", ""); text3 = text3.Replace("&", ""); } } result = text3; return(result); }