IHTMLDocument2 doc = (IHTMLDocument2)browser.Document.DomDocument;
HTMLBody body = (HTMLBody)doc.body;
Bitmap testImage;
foreach (IHTMLImgElement img in doc.images)
{
if (img.src.IndexOf("some text here", 0) != -1)
{
IHTMLControlRange imgRange;
imgRange = (IHTMLControlRange)body.createControlRange();
imgRange.add((IHTMLControlElement)img);
imgRange.execCommand("Copy", false, null);
//captchaUrl = img.GetAttribute("src");
testImage = (Bitmap)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
}
}
Hi guys, this is my third attempt at taking an image from the WebBrowser control. First I tried by src, this game me a bad image. Then I tried to inject javascript, wasen’t successful. Now I am trying this. It is finding the image, but I cant convert it to a Bitmap.
Any help?
Edit: Code is c#
Edit Edit: I just put the WebBrowser control in question on the form to see a visual representation, and the image I am trying to pull isn’t loading. Maybe this is the problem?
1 Answer