Get the HTML source without TWebBrowser

Posted on 2004-11-29
Last Modified: 2011-10-03
I am looking to get the HTML Source code from a page without opening it the tWebBrowser component. Mainly my problem is
that the TWebBrowser component is IE and certain problems occur in my program when I open a page

with a popup
or a javascript error
or a required plugin
or a auto-download

etc etc etc...

So I'm looking for a way to just get the HTML code without "executing" the HTML is this possible?
Question by:ralph44e
    LVL 17

    Expert Comment


    Try this:

    uses URLMon;

    procedure TForm1.Button1Click(Sender: TObject);
      if URLDownloadToFile(nil, '', 'c:\Experts.html', 0, nil) <> 0 then
        MessageBox(Handle, 'Cannot download the file.', PChar(Application.Title), MB_ICONERROR or MB_OK);

    Regards, Geo
    LVL 17

    Expert Comment

    In the example above '' is the link to the page for getting and 'c:\Experts.html' is the local file where the HTML source will be saved.
    LVL 5

    Expert Comment


    You can use Internet Component Suite. Works like a charm and has good samples :-)


    LVL 2

    Accepted Solution

    ok, the code below will allow you do download the source of the web site and I've also added a cute parse so u can check the title of this question, u may not need it but, just showing you what else could be done with the code.

    u will need to add the TIdHTTP which is in the 'indy clients' of your delphi components tab.

    now once you've added the IdHTTP1, put a button1 and a memo1 onto the form.
    procedure TForm1.Button1Click(Sender: TObject);
      buffer: string;
      StoreConfig: TStringList;
    //we will get the source from the web site and put it into a buffer.
    //if you would like to save the web site source we will put it into a
      StoreConfig := TStringList.Create;
    //now we have the source in a buffer what could we do, lets get the Title of the question.
    //the below code will allow you to also download the images with in the source if you was to create the extra code/functions.
    //to finish off lets put it into a memo.
    with the IdHTTP1 you can also add proxy settings and change the requests and lots more.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    This video discusses moving either the default database or any database to a new volume.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now