There is no such thing as "downloading from WebBrowser control". If something is rendered in a
WebBrowser
,
it is already downloaded. It looks like you just need to obtain the images in some files on your local drive. If has nothing to do with a browser, as you probably understand yourself, you really need to use
WebClient
or
HttpWebRequest
(I would advise the second one), but do it correctly. Also, most likely, Web browser cookies, are, most likely, irrelevant. Here is the logic: in first place, you did not have any cookies, but yet you managed to download it all. Instead of cookies, you need to pay attention for authentication itself, through proper
credentials. Please see:
http://stackoverflow.com/questions/19764113/how-to-use-httpwebrequest-credentials-property-for-basic-authentication[
^],
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.credentials%28v=vs.110%29.aspx[
^].
That said, you just need to reproduce exact same client-side action in an HTTP protocol as your browser did. But what to do if you are confusing something which you cannot identify? That often happens in some more tricky situations. I can see two ways to address it:
- Look at the page source very thoroughly and find out what exactly it does. You can do it in a browser using something like "View Page Source".
It can be just some anchor, but it can also be an HTML form, with HTTP parameters passed with name-value keys, according to then name
attributes of the controls of the form; it could be AJAX calls; and then you would need to download all Javascript code and see what it does. - Alternatively, you can use some HTTP spy software and analyze all HTTP requests coming through. It's a pretty simple way when you can ignore many unrelated detail. I, for example, use "HttpFox", a plug-in to the Mozilla browser, but it can be anything else. Such tools are very powerful for Web scraping.
—SA