c# 用System.Net 读取网页源代码
来源:互联网 发布:电脑看图软件 编辑:程序博客网 时间:2024/04/29 22:31
查看了好多抓取网页的代码,有“c#用System.Net读取网页源代码”和“c#用webBrowser读取网页源代码”
都没有如下这样书写的,故先记与此,待进一步考证。
首先引用System.Web.dll;
using System.Net;
using System.IO;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string url="http:www.sina.com";
System.IO.Stream stream=null;
WebClient client=new WebClient();
stream=client.OpenRead(url);
StreamReader readerOfStream = new StreamReader(stream,System.Text.Encoding.GetEncoding("GB2312"));
string aa= readerOfStream.ReadToEnd();
Response.Write(aa);
// Close the stream.
stream.Close();
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
Microsoft Visual Studio .net 2003 下运行成功。
- c# 用System.Net 读取网页源代码
- c# 用System.Net 读取网页源代码
- c# 用System.Net 读取网页源代码(2)
- c# 用System.Net 读取网页源代码(一)
- c# 用System.Net 读取网页源代码(二)
- c# 用webBrowser读取网页源代码
- 用asp.net c# 获取网页源代码
- 用asp.net c# 获取网页源代码
- 用asp读取网页源代码
- 用XMLHTTP读取网页源代码
- 读取网页源代码
- vc++ 读取网页源代码
- 用c# 读取网页内容
- C#网页源代码获取
- C# 获取网页源代码
- c# 获取网页源代码
- c#获取网页源代码
- C#浏览网页源代码
- crm
- (1)Ajax-----Ajax发布
- ASP.NET 2.0异步页
- IT从业人员必看的10个论坛
- objectDataSource多层开发应用
- c# 用System.Net 读取网页源代码
- ASP.NET 2.0模板页和内容页
- Windows下JSP开发环境的配置
- 工作流(2007.2.6)
- ASP.NET 2.0 TEXTBOX 只读后提交数据丢失问题!解决方案!
- 女生写的如何追mm.看完后嫩头青变高手
- MSP430F413单片机实现时钟显示
- 常用链接---000
- 最近在学习javascript,主要是由于要使用ajax要用到的原因