user222427
user222427

Reputation:

C# htmlagility pack , save image from a URL

I know there is a way to save images using WebClient, however, I prefer to use HTMLAgility pack, does anybody have a good example of how to do that?

Upvotes: 2

Views: 3692

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038730

HTML Agility Pack is used for parsing HTML, not for sending HTTP requests and saving images or whatever. So once you have used HTML Agility Pack to parse the HTML and find the url of the image simply use a WebClient to download it from its location:

using (var client = new WebClient())
{
    client.DownloadFile(urlObtainedWithHtmlAgilityPack, "foo");
}

Upvotes: 7

Related Questions