通过asp.net网页下载 [英] download webpage by asp.net

查看:116
本文介绍了通过asp.net网页下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个网址我怎样才能网页下载到我的硬盘用asp.net

given a url how can i download the webpage to my harddrive with asp.net

例如。如果您在IE6打开URL http://www.cnn.com ,并使用文件另存为,它会下载html页面到系统中。

e.g. if you open the url http://www.cnn.com in ie6 and use file save as, it will download the html page to your system.

我如何通过asp.net实现这种

how can i achieve this by asp.net

推荐答案

作为<一个href=\"http://stackoverflow.com/questions/1371406/download-webpage-by-asp-net/1371426#1371426\">womp说,使用Web客户端在我看来简单。这是我简单的例子:

As womp said, using WebClient is simpler in my opinion. Here is my simpler example :

string result;
using (WebClient client = new WebClient()) {
    result = client.DownloadString(address);
}
// Just save the result to a file or do what you want..

这篇关于通过asp.net网页下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆