Page 1 of 1
Re: HTML Document
Posted: Mon Jun 04, 2018 6:26 am
by salvadordf
Read this thread :
https://www.briskbard.com/forum/viewtop ... &t=30&p=74
If you get the HTML before the document is fully loaded then you risk having an incomplete result.
Re: HTML Document
Posted: Wed Jun 06, 2018 6:30 am
by salvadordf
Please post the user agent string you're using to replicate the issue.
Re: HTML Document
Posted: Thu Jun 07, 2018 6:42 pm
by salvadordf
I added this code to the MiniBrowser demo before the GlobalCEFApp.StartMainProcess call :
Code: Select all
GlobalCEFApp.UserAgent := 'Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; Lumia 640 LTE) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537)';
Then I run the MiniBrowser and the mobile version of Google is loaded. After that I right-clicked and selected the "Copy HTML to clipboard" option in the context menu.
It worked correctly, the HTML source was copied to the clipboard and the demo didn't freeze.
Please, check that your app calls TChromium.RetrieveHTML and uses the TChromium.OnTextResultAvailable event like MiniBrowser.
Re: HTML Document
Posted: Sun Jun 10, 2018 10:37 am
by salvadordf
Ideally, you should wait until the main frame is fully loaded before attempting to get the HTML code.
Read these forum threads to know more details :
https://www.briskbard.com/forum/viewtopic.php?f=8&t=261
https://www.briskbard.com/forum/viewtopic.php?f=8&t=333
Re: HTML Document
Posted: Sun Jun 10, 2018 1:22 pm
by salvadordf
The easiest way would be this :
- Use the TChromium.OnLoadingStateChange event and check if isLoading is FALSE before calling TChromium.RetrieveHTML.
- Use the TChromium.OnTextResultAvailable event to receive the HTML in the aText parameter.
If you call TChromium.RetrieveHTML without parameters you will only receive the HTML from the main frame.
If the web page has several frames you will need to read this forum thread :
https://www.briskbard.com/forum/viewtop ... 449&p=1949
If you call TChromium.RetrieveHTML while the page is still loading you may get partial results at best.
Remember that the
MiniBrowser demo has all the code to get the HTML code.
Re: HTML Document
Posted: Sun Jun 10, 2018 2:12 pm
by salvadordf
Then use the ResponseFilterBrowser demo.
It's a much more complicated demo where you can intercept or filter raw resource contents while they are being downloaded but I'm not sure if it works with resources downloaded using JavaScript.
Re: HTML Document
Posted: Sun Jun 10, 2018 4:47 pm
by salvadordf
Nekich wrote: ↑Sun Jun 10, 2018 4:30 pm
it's difficult, can try to get it somehow through ResourceLoadComplete?
And is it possible to pull out the html from browser, frame, request, response?
You would need to call Frame.GetSource with a ICefStringVisitor parameter but that's exactly what TChromium.RetrieveHTML does.
Re: HTML Document
Posted: Sun Jun 10, 2018 5:51 pm
by salvadordf
I don't know. I guess there's a technical reason in Chromium why you have to use a visitor.
The CEF3 API defines what CEF4Delphi calls ICefRequestHandler.OnResourceLoadComplete with those parameters :
https://bitbucket.org/chromiumembedded/ ... capi.h-222