如何使用asp.net从其他网站获取图像src [英] how to get image src from other website using asp.net

查看:73
本文介绍了如何使用asp.net从其他网站获取图像src的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 HtmlDocument document =  new  HtmlDocument(); 
document.Load( url);

foreach (HtmlNode image in document.DocumentElement.SelectNodes( // img [@src))
{
HtmlAttribute url = image [< span class =code-string> src];
imageUrls.Add(url.Value);
}



im使用此代码,但它不能在asp.net上运行它需要System.windows.form命名空间,但我想在我的asp上执行此操作。 net webpage

解决方案

您可以使用System.Net.WebClient类从Web下载任何内容。请参阅此处的说明和示例代码 http://msdn.microsoft.com/en -us / library / ez801hhe(v = vs.110).aspx [ ^ ]


您可以使用 Html Agility Pack [ ^ ]。



查看一个示例和答案 - 如何使用HTML Agility Pack检索网站上的所有图像? [ ^ ]

HtmlDocument document = new HtmlDocument();
document.Load("url");

foreach (HtmlNode image in document.DocumentElement.SelectNodes("//img[@src"))
{
    HtmlAttribute url = image["src"];
    imageUrls.Add(url.Value);
}


i m using this code but it is not working on asp.net it's required System.windows.form namespace but i want to do this on my asp.net webpage

解决方案

You can use System.Net.WebClient class to download any content from the web. See description and sample code here http://msdn.microsoft.com/en-us/library/ez801hhe(v=vs.110).aspx[^]


You can use Html Agility Pack[^].

See one example and the answer - How can I use HTML Agility Pack to retrieve all the images from a website?[^].


这篇关于如何使用asp.net从其他网站获取图像src的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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