Solved

get the source code of current web page in browser

Posted on 2004-08-07
7
279 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 100 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
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11750527
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 93
Working with hours 3 74
TServerSocket - file via sendbuf or Text via sendtext ? 1 76
Can Live bindings change TGrid Cell Colour ? 1 35
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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