Get HTML source from Chromium Embedded

How to do it with Delphi Chromium Embedded Component, I know how to do it with TWebBrowser. But since there are no documents for this, I am sure that someone had the same problem.

thanks

+8
source share
4 answers

This 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; 
+8
source

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; 
+6
source

I really would like to add this as a comment, but I lack a reputation. : / In any case - because I check the HTML source quite often, I declare

 CefStringVisitor := TCefFastStringVisitor.Create(StringVisitor); 

once at the beginning of the program and then use only

 function GetSourceHTML: string; begin Chromium1.Browser.MainFrame.GetSource(CefStringVisitor); end; 

I would like to ask if there is something I need to know about this - maybe this is a bad idea?

0
source

On Delphi XE10 Seattle:

 function TfrmMain.GetSource: String; begin chmBrowser.Browser.MainFrame.GetSourceProc( procedure(const src : string) begin Result := src; end ); end; 
0
source

All Articles