System.Net命名空间中的HttpWebRequest和HttpWebResponse类应该可以帮您的忙。
解决方案 »
- webbrowser设置代理服务器,有用户名密码验证
- 【高分请教】WinForm编程怎么将Textbox里面的内容导出到Excel并保存.
- [新手求助]"{0,-11}= {1}"是什么意思呢?
- 什么叫极限编程啊 !!!1
- RegexOptions.Multiline和RegexOptions.Singleline到底有什么区别
- 各位高手帮忙啊
- 正则表达式,替换问题。
- 数据库设计
- 在线等,这种异常为什么?please help..easy 问题
- 急!当TreeNode没有子节点的时候,能不能手工使TreeNode节点前面变成"+"
- 菜鸟请教程序中用到ShowMessage("...")时,开头该用using +? 谢谢
- 进程计数已禁用怎么解决呀?
HttpWebResponse response ;
string s ;
TextReader tr ;
try
{
request = (HttpWebRequest) WebRequest.Create("要载的");
response = (HttpWebResponse) request.GetResponse() ;
tr = new StreamReader(response.GetResponseStream(),
Encoding.GetEncoding(936)) ;//正确解释汉字
s = tr.ReadToEnd() ;//保存在字符串中,也可以保存在文件中
response.Close() ;
}
catch(Exception e)
{
//出错处理
return ;
}
//对s进行处理
还要我说说正则表达式(System.Text.Regex)的内容吗?
把你的实际情况告诉我吧,我看看要怎么分析。
QQ:25738191
using System.Net;
using System.Text;
//中间的代码不可删除。
//在Form1里加入Label1,Button1,TextBox1,TextBox2四个控件,TextBox2的Multiline属性改为True,能看懂代码意思吧。private void button1_Click(object sender,
System.EventArgs e)
{ byte[] buf = new byte[38192];
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(textBox1.Text);
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Stream resStream = response.GetResponseStream();
int count = resStream.Read(buf, 0, buf.Length);
textBox2.Text = Encoding.Default.GetString(buf, 0,
count);
resStream.Close(); }
比如:
这个网页http://www.abkk.com/cn/train/search_station.asp
看它的源码,发站的name是fzm,到站是dzm,post action 是 search_station_1.asp
这样,比如我想查从沈阳到北京的车,就是这个网页
http://www.abkk.com/cn/train/search_station_1.asp?fzm=沈阳&dzm=北京
不知道我说明白了没有。
有什么问题联系我,我们再讨论。
QQ:25738191
http://www.abkk.com/cn/train/search_station_1.asp?fzm=沈阳&dzm=北京
这是表单get提交的数据,但一般的表单都是Post提交