通过asp.net下载网页 [英] download webpage by asp.net
本文介绍了通过asp.net下载网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如。如果您在ie6中打开网址 http://www.cnn.com ,并使用文件保存为将html页面下载到您的系统。
如何通过asp.net实现这一点?
解决方案
如 womp 所说,使用WebClient是在我看来更简单这是我简单的例子:
string result;
using(WebClient client = new WebClient()){
result = client.DownloadString(address);
}
//只需将结果保存到文件或执行所需操作。
given a url how can i download the webpage to my harddrive with asp.net
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.
how can i achieve this by asp.net
解决方案
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屋!
查看全文