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.

extract values from webpage

dsgfdsagr
Posts: 7
Joined: Mon Jul 19, 2021 10:51 am

Re: extract values from webpage

Post by dsgfdsagr »

Hey, sorry for reviving this post again.
I am having toubles registering the Extention.

when the page loads it does not find the extention.

i am working with subprocess, and declared the Extention as such:

Code: Select all

procedure GlobalCEFApp_OnWebKitInitialized;
begin
{$IFDEF DELPHI14_UP}
  // Registering the extension. Read this document for more details :
  // https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
  TCefRTTIExtension.Register(EXTENTION_NAME, TTestExtension);
//  if TCefRTTIExtension.Register(EXTENTION_NAME, TTestExtension) then
    {$IFDEF DEBUG}CefDebugLog('JavaScript extension registered successfully!'){$ENDIF}
   else
    {$IFDEF DEBUG}CefDebugLog('compile with Delphi 14 and up.!'){$ENDIF};
{$ENDIF}
end;

procedure CreateGlobalCEFApp;
begin
  // In case you prefer to call CreateGlobalCEFApp and DestroyGlobalCEFApp manually
  // you have to remember that GlobalCEFApp can only be initialized *ONCE* per process.
  // This is a CEF requirement and there's no workaround.
  if (GlobalCEFApp <> nil) then
    exit;

  {$IFDEF CEFSUBPROCESS}
  GlobalCEFApp := TCefApplicationCore.Create;
  {$ELSE}
  GlobalCEFApp := TCefApplication.Create;
  GlobalCEFApp.BrowserSubprocessPath := 'SubProcess.exe';
  GlobalCEFApp.OnWebKitInitialized := GlobalCEFApp_OnWebKitInitialized;
  {$ENDIF}

  GlobalCEFApp.StartMainProcess;
end;
where the extention registration should happen? in the subprocess or the calling application browser?

the application is defined as such:

Code: Select all

procedure CreateGlobalCEFApp;
var
  flag:boolean;
begin
  if Assigned(GlobalCEFApp) then
    exit;
  GlobalCEFApp := TCefApplication.Create;
  GlobalCEFApp.BrowserSubprocessPath := 'SubProcess.exe';
  if GlobalCEFApp.StartMainProcess then begin
    GlobalCEFApp.OnWebKitInitialized := GlobalCEFApp_OnWebKitInitialized;
    GlobalCEFApp.LogFile              := 'debug.log';
    GlobalCEFApp.LogSeverity          := LOGSEVERITY_WARNING{LOGSEVERITY_VERBOSE};
  end;
 end;
 
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: extract values from webpage

Post by salvadordf »

GlobalCEFApp.OnWebKitInitialized exposes an ICefRenderProcessHandler event.

All ICefRenderProcessHandler events are executed in the render subprocess so you should add that code to the "SubProcess.exe" project.

This document is a little bit outdated but it has information about this :
https://www.briskbard.com/index.php?lang=en&pageid=cefapp
Post Reply