0

I've been been browsing SO for answers on this and couldn't find a solution. Hopefully someone can be of help with this.

The goal: To collect all images in Web browser 1 - And then to save them to a local file. I don't want to the images to compress in an odd way, I've attempted getting a collection of the images with WebBrowser1.Document.Images and i've also tried to get them coped to a Clipboard(it was of lower quality) -

In my head here's kind of what im thinking:

For each (whatever tag houses img src) - I can grab that, already have, but what's the most effective way to grab ALL images and download them to a folder? Would it be using the method of writing them to memory? Need some help please. I've honestly looked around all over multiple forums and couldn't find a logical answer to this

Jimi
  • 29,621
  • 8
  • 43
  • 61
Byte
  • 143
  • 10
  • 1
    The Document.Images collection contains HtmlElements with Tag ``. You either go get the Image from the URI specified, or get the Image from the WebBrowser (Internet Explorer) Cache. Of course, the Document.Images collection is relative to the main Document; if an HTML page contains IFrames, then you could have Images that are contained in the Document of each IFrame, in separate collections. -- You can get the Images from the cache as a byte array, or get the Stream from the Web - still a byte array - and save the array to disc (with `File.WriteAllBytes()`) – Jimi Feb 06 '21 at 21:17
  • 1
    To get the Images from the Cache, you need [GetUrlCacheEntryInfo](https://learn.microsoft.com/en-us/windows/win32/api/wininet/nf-wininet-geturlcacheentryinfow), which returns a [INTERNET_CACHE_ENTRY_INFO](https://learn.microsoft.com/en-us/windows/win32/api/wininet/ns-wininet-internet_cache_entry_infow) structure. The `lpszLocalFileName` member contains the name of the Image file. If you don't need to show it, you can just copy it somewhere else. -- You need to specify what kind of WebBrowser you're using and what kind of application you're writing (e.g., WinForms, WPF etc.) – Jimi Feb 06 '21 at 21:28
  • Remember that not all the images you see on a webpage are in an ` – Caius Jard Feb 07 '21 at 13:42
  • Also see : [How to get image from WebBrowser control](https://stackoverflow.com/questions/18992562/how-to-get-image-from-webbrowser-control) – Xingyu Zhao Feb 09 '21 at 06:24

0 Answers0