StringBuilder strBuilder = new StringBuilder();
strBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?"); strBuilder.Append("<ROBOT Version=\"2.0\">"); strBuilder.Append("<DiskFreeSpace></DiskFreeSpace>"); strBuilder.Append("<MyFileName>weixin.htm</MyFileName>"); strBuilder.Append("<MyTitle>"); strBuilder.Append(TITLE); strBuilder.Append("</MyTitle>"); strBuilder.Append("<MyURL>"); strBuilder.Append(URL); strBuilder.Append("</MyURL>"); strBuilder.Append("<MyMedia>"); strBuilder.Append(MEDIA); strBuilder.Append("</MyMedia>"); strBuilder.Append("<MyColumn>"); strBuilder.Append(COLUMN); strBuilder.Append("</MyColumn>"); strBuilder.Append("<MyDownTime>"); strBuilder.Append(PUBLISHTIME); strBuilder.Append("</MyDownTime>"); strBuilder.Append("<HaveImage>"); strBuilder.Append(0); strBuilder.Append("</HaveImage>"); strBuilder.Append("<MyInsertTime>"); strBuilder.Append(crawTime); strBuilder.Append("</MyInsertTime>"); strBuilder.Append("<SumImage>"); strBuilder.Append(0); strBuilder.Append("</SumImage>"); strBuilder.Append("<MyComputerName>"); strBuilder.Append("WEIXIN-FA"); strBuilder.Append("</MyComputerName>"); strBuilder.Append("</ROBOT>");string postData = strBuilder.ToString();var encoding = Encoding.GetEncoding("GBK");byte[] buffer = encoding.GetBytes(postData);//创建链接HttpWebRequest request = (HttpWebRequest)WebRequest.Create(webURL);request.Method = "post";request.ContentLength = buffer.Length;request.ContentType = "text/xml";Stream newStream = request.GetRequestStream();byte[] Lastdata = Encoding.GetEncoding("GB2312").GetBytes(postData);newStream.Write(Lastdata, 0, Lastdata.Length);//开始请求,并得到返回值HttpWebResponse res = request.GetResponse() as HttpWebResponse;StreamReader srder = new StreamReader(res.GetResponseStream(), Encoding.GetEncoding("GB2312"));String ret = srder.ReadToEnd();newStream.Close();