Page 1 of 1

Page source code does not work correctly

Posted: Wed Mar 16, 2022 5:01 pm
by Uefi1
Hello, why the source code of the page shows the previous and not the next result ?

Code: Select all

procedure StringVisitor(const source: ustring);
begin
memo1.lines.add(source);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
chrom.Browser.MainFrame.GetSourceProc(StringVisitor);
end;


If you write a loop in the end it works:

Code: Select all

var
html:string;

procedure StringVisitor(const source: ustring);
begin
html:=source;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
html:='';
repeat
chromium1.Browser.MainFrame.GetSourceProc(StringVisitor);
until
html>'0';
memo1.lines.add(html);
end;

Re: Page source code does not work correctly

Posted: Thu Mar 17, 2022 9:37 am
by salvadordf
Hi,

Call TChromiumCore.RetrieveHTML and get the HTML code in the TChromiumCore.OnTextResultAvailable event.

The MiniBrowser demo has an example of this functionality here :
https://github.com/salvadordf/CEF4Delphi/blob/b981543f6359c7aff3df451f5aac39f04fd96746/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1646
https://github.com/salvadordf/CEF4Delphi/blob/b981543f6359c7aff3df451f5aac39f04fd96746/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1190

Re: Page source code does not work correctly

Posted: Thu Mar 17, 2022 9:53 pm
by Uefi1
salvadordf wrote: Thu Mar 17, 2022 9:37 am Hi,

Call TChromiumCore.RetrieveHTML and get the HTML code in the TChromiumCore.OnTextResultAvailable event.

The MiniBrowser demo has an example of this functionality here :
https://github.com/salvadordf/CEF4Delphi/blob/b981543f6359c7aff3df451f5aac39f04fd96746/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1646
https://github.com/salvadordf/CEF4Delphi/blob/b981543f6359c7aff3df451f5aac39f04fd96746/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1190
Thanks while writing a topic already figured out )))
This is working :

Code: Select all


procedure TForm1.Chromium1TextResultAvailable(Sender: TObject;
const aText: ustring);
begin
memo1.lines.add(aText);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Chromium1.OnTextResultAvailable:=Chromium1TextResultAvailable;
Chromium1.RetrieveHTML;
end;