C# 实现向Web网站Post数据
来源:互联网 发布:zepto.js 中文手册 编辑:程序博客网 时间:2024/05/21 09:50
以下是一段通过ip138站点的请求,以查询手机归属地的代码:
- string postData = "mobile=13824162584&action=mobile";
- byte[] bs = Encoding.ASCII.GetBytes(postData);
- WebRequest req = WebRequest.Create("http://www.ip138.com:8080/search.asp");
- req.Method = "POST";
- req.ContentType = "application/x-www-form-urlencoded";
- req.ContentLength = bs.Length;
- using (Stream reqStream = req.GetRequestStream())
- {
- reqStream.Write(bs, 0, bs.Length);
- }
- using (WebResponse wr = req.GetResponse())
- {
- //在这里对接收到的页面内容进行处理
- Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
- string tempStr = "";
- string sb = "";
- Stream receviceStream = wr.GetResponseStream();
- while(true)
- {
- byte[] read = new byte[1024];
- int iBytes = receviceStream.Read(read, 0, read.Length);
- if (0 == iBytes)
- {
- break;
- }
- if (iBytes < read.Length)
- {
- byte[] buf = new byte[iBytes];
- for (int i = 0; i < iBytes; i++)
- {
- buf[i] = read[i];
- }
- tempStr = encode.GetString(buf);
- sb += tempStr;
- }
- else
- {
- tempStr = encode.GetString(read);
- sb += tempStr;
- }
- }
- }
- C# 实现向Web网站Post数据
- C# 向web网站GET、POST 数据
- [转]C# 向web网站GET、POST 数据
- [转]C# 向web网站GET、POST 数据
- [转]C# 向web网站GET、POST 数据
- asp.net C# 向web网站GET、POST 数据
- C++ 向网站post数据
- MFC向指定网站post数据
- Android 实现Post向服务器提交数据
- c#中httpwebRequest Post数据到网站
- c# Post数据到web服务器
- Android向Web服务器发送Post请求并返回数据
- 向WEB服务器GET,POST数据(C++代码)
- Android向Web服务器发送Post请求并返回数据
- 前台post通过web api向数据库中添加数据
- 实现程序向网站的POST (MFC版)
- 向Web站点发送GET请求,POST请求,并从Web站点取得相应数据示例
- 模拟向服务器POST数据
- 传闻:微软 Silverlight 2 明天发布
- 这里在发展
- 函数参数的压栈顺序
- silverlight学习笔记(1)
- Linux磁盘配额
- C# 实现向Web网站Post数据
- MFC:来龙去脉
- 拼包函数及网络封包的异常处理(含代码)
- MFC:学习杂记之一
- Class.forName( )你搞懂了吗?
- 每个Java初学者都应该搞懂的六个问题
- 用 Spring MVC 来处理向导式复杂表单
- C#专题-导读:C#语言学习纲要
- Using OpenCV with MFC