QQRead:http://www.qqread.com/csharp/k314900.html
下载页面中图片:
//下载图片
public void Get_Img(string a_strUrl,int timeout,string filepath)
{
try
{
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(a_strUrl) ;
myReq.Timeout = timeout;
HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse();
Stream myStream = HttpWResp.GetResponseStream () ;
Bitmap map = new Bitmap( myStream );
PictureBox picB = new PictureBox();
picB.Image = (Image)map;
string path = filepath.Substring( 0,filepath.LastIndexOf( "\\" ) );
if (!Directory.Exists(path))
{
CreateDir( path );
}
picB.Image.Save(filepath);
}
catch(Exception exp)
{
string ss = exp.Message;
WriteLog( filepath.Substring(0,filepath.LastIndexOf("\\")) + "\\error.log",a_strUrl + "--" + ss + "\r\n");
}
}
保存文件或入库
上面取得的信息可以按自己的要求保存。
****设计的时候没有使用url按层次循环抓取,这样定义抓取url效率更高,速度更快。
如有建议请发送EMail:xiancai@qianlong.com 或msn yutao728@hotmail.com
注:此版本只提供静态文件存储功能,不提供数据库接口,不提供自定义网站功能。
本程序运行需要先安装.net 框架1.1。
进入讨论组讨论。
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- C#变得越来越臃肿是不可避免的? (7次浏览)
- C# 3.0新特性之扩展方法 (1次浏览)
- 实验分析C#中三种计时器使用异同点 (0次浏览)
- C#调用QTP自动化对象模型的实例 (0次浏览)
- 利用 C# 实现任务栏通知窗口 (0次浏览)
- 深入C#学习系列之不可小瞧的using关键字 (0次浏览)
- 如何用.NET技术在线生成网站LOGO (0次浏览)
- C#实现遗传算法 模拟花朵的进化 (0次浏览)
- c#里的运算符重载 (0次浏览)
- QTP调用自己开发的.net类库 (0次浏览)



