欢迎访问我的博客 https://javascript.shop

图片下载

原文发布时间为:2010-06-29 —— 来源于本人的百度文章 [由搬家工具导入]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mshtml;

public partial class Default22 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
IHTMLDocument2 doc = new HTMLDocumentClass();
ESpace.Common.IESimulator ie = new ESpace.Common.IESimulator();
ie.Url = "http://www.baidu.com";
ie.GetPageCode();

doc.write(new object[] { ie.OutString });
doc.close();
if (doc != null)
{
List<string> urls = new List<string>();
for (int i = 0; i < doc.images.length; i++)
{
IHTMLElement element = doc.images.item(i, 0) as IHTMLElement;
string url = element.getAttribute("src", 0).ToString();
if (url.Trim() != "" && !urls.Contains(url))
{
urls.Add(url);
Response.Write(url + ",");
ie.SaveImageFromUrl(Server.MapPath(".") + "/Down/" + DateTime.Now.ToString("yyyymmddhhmmss")+i.ToString() + ".gif", url);
}
}
}
}

}
posted @ 2017-07-14 00:56  孑孓子  阅读(233)  评论(0编辑  收藏  举报
欢迎访问我的博客 https://javascript.shop