c# 用System.Net 读取网页源代码(2)
2007-02-07 11:30
232 查看
接上一篇,这是普遍采用的 c# 用System.Net 读取网页源代码 的书写方式。
System.Net.HttpWebRequest req;
System.Net.HttpWebResponse res;
string url="http://www.92liao.cn";
req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
res = (System.Net.HttpWebResponse)req.GetResponse();
System.IO.StreamReader strm = new System.IO.StreamReader(res.GetResponseStream(), System.Text.Encoding.GetEncoding("gb2312"));
string aa=strm.ReadToEnd();
Response.Write(aa);
方法2
在WindowsApplication 用WebBrowser控件实现 读取网页。
在工具箱里右击,选添加/删除选项,在弹出的对话框里选Com组件选项卡,找到
Microsoft Web 浏览器 选定 后确定, 在工具箱里选择WebBrowser控件,拖放到窗体上,然后写代码:
private void Form1_Load(object sender, System.EventArgs e)
{
string str="";
System.Object nullObject=0;
System.Object nullObjStr=str;
this.axWebBrowser1.Navigate("www.88te.net",ref nullObject,ref
nullObjStr,ref nullObjStr,ref nullObjStr);
}
System.Net.HttpWebRequest req;
System.Net.HttpWebResponse res;
string url="http://www.92liao.cn";
req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
res = (System.Net.HttpWebResponse)req.GetResponse();
System.IO.StreamReader strm = new System.IO.StreamReader(res.GetResponseStream(), System.Text.Encoding.GetEncoding("gb2312"));
string aa=strm.ReadToEnd();
Response.Write(aa);
方法2
在WindowsApplication 用WebBrowser控件实现 读取网页。
在工具箱里右击,选添加/删除选项,在弹出的对话框里选Com组件选项卡,找到
Microsoft Web 浏览器 选定 后确定, 在工具箱里选择WebBrowser控件,拖放到窗体上,然后写代码:
private void Form1_Load(object sender, System.EventArgs e)
{
string str="";
System.Object nullObject=0;
System.Object nullObjStr=str;
this.axWebBrowser1.Navigate("www.88te.net",ref nullObject,ref
nullObjStr,ref nullObjStr,ref nullObjStr);
}
相关文章推荐
- c# 用System.Net 读取网页源代码(一)
- c# 用System.Net 读取网页源代码(二)
- c# 用System.Net 读取网页源代码
- c# 用System.Net 读取网页源代码 1
- c# 用System.Net 读取网页源代码
- [ASP.NET]c#利用WebClient和WebRequest类获得网页源代码
- c# 用webBrowser读取网页源代码
- 用asp.net c# 获取网页源代码
- ASP.NET使用HttpWebRequest读取远程网页源代码
- C# 提交网页请求时出现如下错误: System.Net.WebException: 操作超时
- C# 读取网页源代码
- HOW TO:使用 System.IO 和 Visual C# .NET 读取文本文件
- 用asp.net(c#)获取网页源代码(两种方法)
- 用asp.net c# HttpWebRequest获取网页源代码
- asp.net C# 获取网页源代码的几种方式
- 用asp.net c# 获取网页源代码
- c#.net(B/s)读取图片,并输出到网页上,可起图片防盗作用
- 用asp.net(c#)获取网页源代码(两种方法)
- 用asp.net c# 获取网页源代码
- c#.net(B/s)读取图片,并输出到网页上,可起图片防盗作用