0

I want to read a view source of any web page and want to download all images in a folder.

I use below code to read page source:

    string address = "http://stackoverflow.com/";  //any web site url

    using (WebClient wc = new WebClient())
    {
        txtRead .Text= wc.DownloadString(address);            
    }

But in this view source how to get only img src and download images in a local folder.

Thanks, Hitesh

Hitesh
  • 1,188
  • 5
  • 30
  • 52

1 Answers1

0

If you use HtmlAgilityPack you can do something like this

 HtmlDocument doc = new HtmlDocument();
 doc.LoadHtml(yourHtml);
 foreach(HtmlNode imagein doc.DocumentElement.SelectNodes("//img)
 {
    HtmlAttribute src = link["src"];
    CodeToDownloadTheImage(src);
 }

See this question for more info.

Community
  • 1
  • 1
Peter Morris
  • 20,174
  • 9
  • 81
  • 146