如何用C#实现下载整个网页!(包括其中的动画,声音,FLASH什么的!)

nyucv 2005-06-07 09:52:27
如何用C#实现下载整个网页!(包括其中的动画,声音,FLASH什么的!)类假IE的另存为功能!
...全文
282 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
nyucv 2005-06-09
  • 打赏
  • 举报
回复
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
HtmlToMht("http://www.163.net", "c:\\csdn.mht");
}


public static void HtmlToMht(string src, string dst)
{
CDO.Message msg = new CDO.MessageClass();

CDO.Configuration c = new CDO.ConfigurationClass();
msg.Configuration = c;
//msg.
msg.CreateMHTMLBody(src, CDO.CdoMHTMLFlags.cdoSuppressAll, "domain\\username", "password");

ADODB.Stream stream = msg.GetStream();
stream.SaveToFile(dst, ADODB.SaveOptionsEnum.adSaveCreateOverWrite);
//Console.WriteLine(msg.GetStream().ReadText(100));
}
这代码我在2003下运行.为什么老说空引用呢???????头晕中!!!1
itmingong 2005-06-08
  • 打赏
  • 举报
回复
up
hky5_com 2005-06-08
  • 打赏
  • 举报
回复
up
crescentcn 2005-06-08
  • 打赏
  • 举报
回复
WebRequest
bflovesnow 2005-06-08
  • 打赏
  • 举报
回复
WebRequest
symboltome 2005-06-08
  • 打赏
  • 举报
回复
前写日子 写了一些 你可以参考 参考 然后 类推就可以啦
public string GetPageSource(string url)//获取网页的html代码
{
Uri uri=new Uri(url);
HttpWebRequest hwReq=(HttpWebRequest)WebRequest.Create(uri);
HttpWebResponse hwRes=(HttpWebResponse)hwReq.GetResponse();
hwReq.Method="Post";
hwReq.KeepAlive=false;
StreamReader reader=new StreamReader(hwRes.GetResponseStream(),System.Text.Encoding.GetEncoding("GB2312"));
return reader.ReadToEnd();
}
public static ArrayList GetHyperLinks(string httpcode)//获取html代码中所有的连接
{
ArrayList al = new ArrayList();
string strRegex = @"http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?";
Regex r = new Regex(strRegex,RegexOptions.IgnoreCase);
MatchCollection m = r.Matches(httpcode);
for(int i=0; i<=m.Count-1; i++)
{
bool rep = false;
string strNew = m[i].ToString();
// 过滤重复的URL
foreach(string str in al)
{
if(strNew==str)
{
rep =true;
break;
}
}
if(!rep) al.Add(strNew);
}
al.Sort();
return al;
}
zr1982930 2005-06-08
  • 打赏
  • 举报
回复
没做过,帮你顶一下!
seekg 2005-06-08
  • 打赏
  • 举报
回复
up
nyucv 2005-06-08
  • 打赏
  • 举报
回复
头痛!这正则表达式要是一下能写出来就好了!

现在问题是SRC=",,,,,",背影图片地址这一类的地址得不到呀!头痛中!
nik_Amis 2005-06-08
  • 打赏
  • 举报
回复
up
yizhixiaozhu 2005-06-07
  • 打赏
  • 举报
回复
要详细分析源代码
才能下载全部
ToString 2005-06-07
  • 打赏
  • 举报
回复
webRequest
fanruinet 2005-06-07
  • 打赏
  • 举报
回复
要分析取回的html页,取出其中的链接,将相对地址转换成绝对地址,下载文件,还要把html页中的绝对地址转换成本地磁盘上的下载回来的文件的相对地址

我没仔细想,你自己把步骤什么的再完善一下吧

主要命名空间是System.Net,用正则表达式可能会方便些,命名空间System.Text.RegularExpressions
xiaopai20 2005-06-07
  • 打赏
  • 举报
回复
可能要自己读一篇HTML里的SRC,再取相应的文件

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧