Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Page source code does not work correctly

Post Reply
User avatar
Uefi1
Posts: 37
Joined: Tue Aug 24, 2021 1:58 pm

Page source code does not work correctly

Post 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;
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Page source code does not work correctly

Post 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
User avatar
Uefi1
Posts: 37
Joined: Tue Aug 24, 2021 1:58 pm

Re: Page source code does not work correctly

Post 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;

Post Reply