Get HTML Source from Chromium Embedded
Asked Answered
C

2

8

How to do this with Delphi Chromium Embedded Component i know how to do this with TWebBrowser. But since no docs are present for this I am sure someone else had same problem.

Thanks

Columbia answered 10/11, 2012 at 17:6 Comment(0)
C
8

Here is how you do it..

procedure TCustomLoad.OnLoadEnd(const browser: ICefBrowser;
  const frame: ICefFrame; httpStatusCode: Integer);
  var
  data:tstringlist;
begin
  data:=tstringlist.create;
  if frame.IsMain then
  data.text:=frame.Source; // HTML Source    
end;
  data.free;
end;
Columbia answered 10/11, 2012 at 18:12 Comment(0)
E
7

in dcef 3

procedure StringVisitor(const str: ustring);
begin
  //str is the SourceHtml
showmessage(str);
end;

function GetSourceHTML: string;
var
CefStringVisitor:ICefStringVisitor;
begin
  CefStringVisitor := TCefFastStringVisitor.Create(StringVisitor);
  Chromium1.Browser.MainFrame.GetSource(CefStringVisitor);
end;
Enrich answered 8/3, 2014 at 8:33 Comment(2)
Warning : StringVisitor procedure is called asynchronouslyBespoke
@STBLand In this case it seems the page is reloaded. How to get the source without reloading the page ?Yatzeck

© 2022 - 2024 — McMap. All rights reserved.