I want to download images from a website to check against other dynamic information on the site which is loaded in via AJAX. Since the site uses AJAX to load in the other information I can't use an invoke-webrequest because the ajax information doesn't load or at least I can't figure out how to trigger it. For that reason I decided to use a com object of Application.internetexplorer.
This works to traverse and trigger the javascript but I can't figure out how to save the picture that is being displayed in the IE window. I've tried to download the image via the src path but, as stated previously, the image changes from the original state slightly on every request. There is no 'save' method that I can see from $ie.document.images or any other path. I've tried to out-file to a .png as innerHTML or outerHTML etc. as a last ditch effort but that all fails as well.
I can see the picture when I make the com object visible. There must be some way to grab that image which is already displaying on my computer. Does anyone know how I could accomplish this?
Not sure it Helps but here is my code so far:
$url = "https://somesite.com"
$ie = New-Object -com internetexplorer.application
$ie.navigate($url)
while($ie.ReadyState -ne 4) {start-sleep -seconds 1}
$ie.visible = $true
$doc = $ie.Document
$firstImage= $doc.IHTMLDocument3_getElementById('images01')
$secondImage = $doc.IHTMLDocument3_getElementById('images02')
$thirdImage = $doc.IHTMLDocument3_getElementById('images03')
#how can I save firstImage as .png?