Problem getting HTML source of page.
Posted: Sat Mar 22, 2025 12:00 am
Hi all,
I'm having problems getting a page's HTML source. I'm initiating the loading with TChromium.LoadURL, with a callback OnLoadEnd that is basically copied from the mini browser :
What turns up in the src is only a couple of lines.
So I tried retrieving the frame source using :
Again this produces only a couple of lines of source, certainly not the source for the full page.
The odd thing is if I right click on the browser output window with the loaded page, and select view page source, a notepad window opesn with the full source of the page. What am I doing wrong?
Cheers.
Phill.
I'm having problems getting a page's HTML source. I'm initiating the loading with TChromium.LoadURL, with a callback OnLoadEnd that is basically copied from the mini browser :
Code: Select all
procedure TBrowserForm.ChromeLoadEnd(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
httpStatusCode: Integer);
begin
Debug.Log('ChromeLoadEnd() code=%d',[httpStatusCode]);
if (browser <> nil) and (browser.Identifier = Chrome.BrowserId) and ((frame = nil) or (frame.IsMain)) then
begin;
IF (frame.IsMain) THEN
BEGIN;
Chrome.Browser.MainFrame.GetSourceProc(ChromeCallbackGetSource);
ChromeBusy:=FALSE;
END;
end;
end;
procedure ChromeCallbackGetSource(const src: ustring);
begin
BrowserForm.FChromeSrc:=src;
Debug.Log(src);
IF (BrowserForm.Handlers.IsHTMLHandler) THEN
BrowserForm.GoHtml(TRUE,src)
ELSE
BrowserForm.Handlers.ChromeDone(src);
BrowserForm.Ready:=TRUE;
end;
So I tried retrieving the frame source using :
Code: Select all
procedure TBrowserForm.Button2Click(Sender: TObject);
VAR
i : NativeUInt;
TempCount : NativeUInt;
TempArray : TCefFrameIdentifierArray;
TempString : string;
begin
TempCount := Chrome.FrameCount;
if Chrome.GetFrameIdentifiers(TempCount, TempArray) then
begin
TempString := '';
i := 0;
while (i < TempCount) do
begin
TempString := TempString + inttostr(TempArray[i]) + CRLF;
Debug.Log('FrameID:%d',[TempArray[i]]);
Chrome.RetrieveHTML(TempArray[i]);
inc(i);
end;
Debug.Log(TempString);
end;
end;
procedure TBrowserForm.ChromeTextResultAvailable(Sender: TObject;
const aText: ustring);
BEGIN;
Debug.Log(atext);
end;
The odd thing is if I right click on the browser output window with the loaded page, and select view page source, a notepad window opesn with the full source of the page. What am I doing wrong?
Cheers.
Phill.