I used the code below to successfully get a copy of each picture inside a page loaded using webbrowser control.
Dim doc As IHTMLDocument2 = DirectCast(wb.Document.DomDocument, IHTMLDocument2)
Dim imgRange As IHTMLControlRange = DirectCast(DirectCast(doc.body, HTMLBody).createControlRange(), IHTMLControlRange)
For Each img As IHTMLImgElement In doc.images
imgRange.add(DirectCast(img, IHTMLControlElement))
imgRange.execCommand("Copy", False, Nothing)
Using bmp As Bitmap = DirectCast( _
Clipboard.GetDataObject().GetData(DataFormats.Bitmap), Bitmap)
bmp.Save(img.nameProp)
End Using
Next
I got the code from here: Copy an image from cache of web browser control present in VB.NET
However, the picture I am interested in is inside an iFrame.
I tried changing:
Dim doc As IHTMLDocument2 = DirectCast(wb.Document.DomDocument, IHTMLDocument2)
to
Dim doc As IHTMLDocument2 = DirectCast(wb.Document.Window.Frames(iFrameID).Document.DomDocument, IHTMLDocument2)
but I am getting an "Access Denied" Error. I guess (not sure) its because the iframe's src is on a different domain.
Is there a way around this problem?
Thanks!