用httpwebrequest抓取网页,然后用正则或者查找字符串分析
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070210http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070210http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
解决方案 »
- DateTimePicker與Null的問題!
- System.ObjectDisposedException: 无法访问已释放的对象。
- 论坛问题.....
- 关于报表的问题
- 【采集】C# 写一客户端,采集某网站的信息数据,但对方网站有限制采集间隔,求解决方案??
- 请教:web中显示图片
- 7天了!快崩溃了!关于datagridview控件“尝试读取或写入受保护的内存。这通常指示其他内存已损坏。”错误求解?
- datagridview如何强制某列为日期yyyy-mm-dd形式?也就是datetime型呢?
- 又是读文件的问题,再请各位过来帮忙看看~~
- Visual Studio .NET安装说明
- 项目中取绝对路径
- javascript return "aa";怎么在button事件中得到这个值?
WebClient wb = new WebClient(); byte[] pageData = wb.DownloadData(@url); //转换字符
string result = Encoding.Default.GetString(pageData); //替换内容
//string str = result.Replace("\"","");
//str=str.Replace("onclick=if(this.width>=700) window.open","").Replace("onload=if(this.width>'700')this.width='700';","").Replace("删除","").Replace("[","").Replace("]","").Replace("图片:","");
RegexOptions ss=RegexOptions.None;
Regex rr=new Regex("<[^<>]+>",ss);
可以得出表里的每项数据!
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace testf
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private static bool CopyData(System.IO.Stream FromStream, System.IO.Stream ToStream)
{
try
{
int intBytesRead;
const int intSize = 4096;
Byte[] bytes = new Byte[intSize];
intBytesRead = FromStream.Read(bytes, 0, intSize);
while (intBytesRead > 0)
{
ToStream.Write(bytes, 0, intBytesRead);
intBytesRead = FromStream.Read(bytes, 0, intSize);
}
return true;
}
catch (Exception myError)
{
return false;
} }
public static bool DownloadFile(string remoteurl, System.IO.Stream Stream)
{
System.Net.WebRequest req;
try
{
req = System.Net.WebRequest.Create(remoteurl);
req.Method = "GET";
System.Net.WebResponse rsp = req.GetResponse(); return CopyData(rsp.GetResponseStream(), Stream);
}
catch (Exception myError)
{
return false;
}
}
private void button1_Click(object sender, EventArgs e)
{
System.IO.MemoryStream ms=new System.IO.MemoryStream ();
DownloadFile(@"http://www.ccb.com/portal/cn/finance_quote/fundnetvalueinfo.jsp", ms);
int size = Convert.ToInt32(ms.Length);
ms.Position = 0;
Byte[] bytes = new Byte[size];
ms.Read(bytes, 0, size);
System.Text.Encoding ed= System.Text.Encoding.GetEncoding("GB2312");
string s = ed.GetString(bytes);
MessageBox.Show(s);
//自己分析 吧 }
}
}