使用 HttpWebRequest 轻松实现站外提交
来源:互联网 发布:迷宫的十字路口 知乎 编辑:程序博客网 时间:2024/06/06 21:19
HttpWebRequest post=(HttpWebRequest)WebRequest.Create(targetUrl);
post.Method = "post";
post.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
String postData = "";
if(url!=null)
postData += "url=" + HttpUtility.UrlEncode(url);
if (blog_name != null)
postData += "&blog_name=" + HttpUtility.UrlEncode(blog_name);
if (title != null)
postData += "&title=" + HttpUtility.UrlEncode(title);
else
postData += "&title=" + HttpUtility.UrlEncode(url);
if (excerpt != null)
postData += "&excerpt=" + HttpUtility.UrlEncode(excerpt);
UTF8Encoding encoding = new UTF8Encoding();
byte[] buff = encoding.GetBytes(postData);
post.ContentLength = buff.Length;
Stream stream = post.GetRequestStream();
stream.Write(buff,0,buff.Length);
stream.Flush();
stream.Close();
post.BeginGetResponse(null,null);
HttpWebResponse rep = (HttpWebResponse)post.GetResponse();
Stream repStream = rep.GetResponseStream();
Encoding enc = Encoding.GetEncoding(rep.CharacterSet);
StreamReader reader = new StreamReader(repStream,enc);
String content = reader.ReadToEnd();
- 使用 HttpWebRequest 轻松实现站外提交
- 使用 HttpWebRequest 轻松实现站外提交(可用于自动登陆,自动网上投票等)
- 使用 HttpWebRequest 轻松实现站外提交(可用于自动登陆,自动网上投票等) (转)
- 使用HttpWebRequest提交信息
- 站外提交,HttpWebRequest,WebResponse(推荐)
- 使用HttpWebRequest提交表单数据
- 使用 HttpWebRequest 向网站提交数据
- 使用 HttpWebRequest 向网站提交数据
- 使用 HttpWebRequest 向网站提交数据
- 使用 HttpWebRequest 向网站提交数据
- 使用 HttpWebRequest 向网站提交数据
- 使用 HttpWebRequest 向网站提交数据
- 使用 HttpWebRequest 向网站提交数据【转】
- 使用 HttpWebRequest 向网站提交数据
- 使用 HttpWebRequest 向网站提交数据
- 使用HttpWebRequest向网站提交数据
- 使用 HttpWebRequest 向网站提交数据
- C#中使用HttpWebRequest提交MultiPart数据
- APS.net執行流程圖
- VS.net 2005, 没有找到MSVCR80D.dll的完美解决方案
- 关于struts中数据库的使用
- Vss 2005在局域网中的使用
- 国际化问题解决方案
- 使用 HttpWebRequest 轻松实现站外提交
- 关于nullpointer
- 关于ICSharpCode.SharpZipLib控件的问题
- 过滤器filter-解决乱码的问题
- MS SQL Server查询优化方法
- struts基本套路
- JavaScript 的正则表达式
- Security check diff between Everett and Whidbey
- Windows Management Instrumentation (WMI)