?
Solved

get the source code of current web page in browser

Posted on 2004-08-07
7
Medium Priority
?
281 Views
Last Modified: 2010-04-04
Hi,

Is there a way to read the source code of current web page in browser(ie, netscape, if more will be better)

Regards
0
Comment
Question by:wangzheng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 10

Expert Comment

by:kiranghag
ID: 11745251
not sure in delphi, but if you can make a http connection through network programming, you can get the source.
by this smethod, u cannot get the source for the pages which do not need to establish a session (e.g webmail)
but can get pages which can be accessed by the url directly.
0
 
LVL 2

Expert Comment

by:Bobcsi
ID: 11745949
You get the URL in IExplorer with this code:

uses
  DDEMan;

// TForm type declaration...

procedure TForm1.Button1Click(Sender: TObject);
var
  DDE: TDDEClientConv;
begin
  DDE := TDDEClientConv.Create(self);
  if DDE.SetLink('IExplore', 'WWW_GetWindowInfo') then
    Memo1.Lines.Add(DDE.RequestData('0xFFFFFFFF,sURL,sTitle'));
  DDE.Free;
end;


Then, you download this page with indy HTTP Client components.


var s1:ansistring;
begin
  s1:=idhttp1.Get('http://www.url.com');
end;
0
 
LVL 4

Accepted Solution

by:
ErikPhilips earned 400 total points
ID: 11746170
If you want to write an app that reads the source from all IEs loaded:
(I believe this works properly, i have a lot of extra code to make sure all the sites are valid (ie not Images or Text files)).

procedure SomProcedure;
var
  ShellWin: IShellWindows;
  i: Integer;
  iWeb: IWebbrowser2;
  iDoc: IHTMLDocument2;
  tmpHwnd: tHwnd;
begin

  ShellWin := CoShellWindows.Create;
  for i := 0 to ShellWin.Count - 1 do
  begin
    iWeb := ShellWin.Item(i) as IWebbrowser2;
    try
      if (pos('http://', iWeb.Get_LocationURL) = 1) then  // could add https://
      begin
        try
          iDoc :=(iWeb.document as IHTMLDocument2);
          if (iDoc.protocol = 'HyperText Transfer Protocol') then
           begin
              htmlTitle := idoc.title;
              htmlURL := idoc.url;
              htmlSource := iDoc.body.innerHTML; //  This is the source as the browser recieved it, does not contain changes from scripts
           end;
        except
        end;
      end;
    except
    end;
  end;
  ShellWin.Free;
end;





0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 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