Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7558457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:22:38+00:00 2026-05-30T12:22:38+00:00

IHTMLDocument2 doc = (IHTMLDocument2)browser.Document.DomDocument; HTMLBody body = (HTMLBody)doc.body; Bitmap testImage; foreach (IHTMLImgElement img in

  • 0
    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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:22:40+00:00Added an answer on May 30, 2026 at 12:22 pm
    /*
     * A function to get a Bitmap object directly from a web resource
     * Author: Danny Battison
     * Contact: gabehabe@googlemail.com
     */
    
    /// <summary>
    /// Get a bitmap directly from the web
    /// </summary>
    /// <param name="URL">The URL of the image</param>
    /// <returns>A bitmap of the image requested</returns>
    public static Bitmap BitmapFromWeb(string URL)
    {
        try {
            // create a web request to the url of the image
            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);
            // set the method to GET to get the image
            myRequest.Method = "GET";
            // get the response from the webpage
            HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
            // create a bitmap from the stream of the response
            Bitmap bmp = new Bitmap(myResponse.GetResponseStream());
            // close off the stream and the response
            myResponse.Close();
            // return the Bitmap of the image
            return bmp;
        } catch (Exception ex) {
            return null; // if for some reason we couldn't get to image, we return null
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get all mshtml.IHTMLDivElement from IHTMLDocument2 ? private mshtml.IHTMLDocument2 doc = (IHTMLDocument2)WPFBrowser.Document; ???
I am using this code try document := (pDisp as IWebbrowser2).Document AS IHTMLDocument2; Body
Trying to get this line to work mshtml.IHTMLDocument2 doc2 = webBrowser1.Document as mshtml.IHTMLDocument2; but
I am writing a BHO, the code using IHTMLDocument2::get_scripts to get all script body
When this code is executed, the src and alt are set correctly, but border
I have written a browser helper object to get the text between the tags
I have a web browser control embedded in a form . Upon form load
I have a webbrowser and I use DocumentComplete to read the current document from
We are developing an application which needs to interact with the active document in
I'm using this code to get all the links from an IHTMLDocument2: procedure DoDocumentComplete(const

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.