c#使用post,get请求网页
来源:互联网 发布:平板软件市场hd 编辑:程序博客网 时间:2024/05/01 10:32
get方式:
string url = "http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true";
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
Stream s = response.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.GetEncoding("gb2312"));
MessageBox.Show(sr.ReadToEnd());
sr.Dispose();
sr.Close();
s.Dispose();
s.Close();
post方式:
string url = http://maps.googleapis.com/maps/api/geocode/json;
string postData = "address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true";
WebRequest request = WebRequest.Create(url);
request.Method = "Post";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postData.Length;
StreamWriter sw = new StreamWriter(request.GetRequestStream());
sw.Write(postData);
sw.Flush();
WebResponse response = request.GetResponse();
Stream s = response.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.GetEncoding("gb2312"));
MessageBox.Show(sr.ReadToEnd());
sw.Dispose();
sw.Close();
sr.Dispose();
sr.Close();
s.Dispose();
s.Close();
- c#使用post,get请求网页
- C#请求网页(Get、Post)
- C#请求网页(Get、Post)
- C#使用GET、POST请求获取结果
- C#使用GET、POST请求获取结果
- C#使用GET、POST请求获取结果
- C#使用GET、POST请求获取结果
- C#使用GET、POST请求获取结果
- C#使用GET、POST请求获取结果
- C#使用GET、POST请求获取结果
- C#使用GET、POST请求获取结果
- C# HttpWebRequest使用GET、POST请求获取结果
- C#使用GET、POST请求获取结果 (二)
- C#实现http协议GET、POST请求
- C#实现http协议GET、POST请求
- C# 实现http协议GET、POST请求
- C# 实现HTTP GET POST请求
- C#实现http协议GET、POST请求
- c++笔记17之句柄类
- ubuntu12.04虚拟机硬盘扩容
- 关于网站防SQL注入使用关键字过滤和SQL注入
- 根据浏览器的版本为网页应用不同的 CSS 样式表文件
- Raising Modulo Numbers 解题报告
- c#使用post,get请求网页
- poj 3126Prime Path
- 电商创新模式-食品类-LoveWithFood:每月送来一份惊喜的另类电商
- GridSplitter的使用
- Qt实现窗口自动隐藏
- Winfrom c# 两个ComboBox互相联动
- struts2 访问静态常量,静态方法
- linux下vim命令详解
- iBatis配置详解