日期:2014-05-18 浏览次数:20526 次
Encoding utf8 = Encoding.UTF8; Encoding gbk = Encoding.GetEncoding("gbk"); byte[] tmp = utf8.GetBytes(URL); byte[] tmp1 = Encoding.Convert(utf8, gbk, tmp); string result = gbk.GetString(tmp1); byte[] buffer = Encoding.UTF8.GetBytes(result); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(URL); ////做请求 req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = buffer.Length; Stream reqst = req.GetRequestStream(); reqst.Write(buffer, 0, buffer.Length); reqst.Flush(); reqst.Close(); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); //读结果 Stream resst = res.GetResponseStream(); StreamReader sr = new StreamReader(resst); XmlDocument rssDoc = new XmlDocument(); rssDoc.Load(resst); XmlNode rss = rssDoc.SelectSingleNode("result/response"); string DHResult = rss.Attributes[0].Value.ToString(); resst.Close(); sr.Close(); return DHResult;