日期:2014-05-18 浏览次数:20947 次
Encoding myEncoding = Encoding.GetEncoding("gb2312"); string param = HttpUtility.UrlEncode("参数一", myEncoding) + "=" + HttpUtility.UrlEncode("值一", myEncoding) + "&" + HttpUtility.UrlEncode("参数二", myEncoding) + "=" + HttpUtility.UrlEncode("值二", myEncoding); byte[] postBytes = Encoding.ASCII.GetBytes(param); HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create( "http://www.baidu.com/s" ); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded;charset=gb2312"; req.ContentLength = postBytes.Length; using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(bs, 0, bs.Length); } using (WebResponse wr = req.GetResponse()) { //在这里对接收到的页面内容进行处理 }