首页 > 代码库 > cef3 获得 谷歌浏览器 网页源码 哈哈

cef3 获得 谷歌浏览器 网页源码 哈哈

Get HTML Source from Chromium Embedded

http://stackoverflow.com/questions/13324095/get-html-source-from-chromium-embedded

up vote6down votefavorite
1

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

delphi google-chrome delphi-xe2 tchromium
shareimprove this question
edited Nov 10 ‘12 at 18:12
 
 
asked Nov 10 ‘12 at 17:06
 
user1647411
 
 
add a comment

2 Answers

activeoldestvotes
up vote7down voteaccepted

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;
shareimprove this answer
edited Nov 12 ‘12 at 22:02
 
 
answered Nov 10 ‘12 at 18:12
 
user1647411
 
 
add a comment
 
up vote4down vote

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;

cef3 获得 谷歌浏览器 网页源码 哈哈