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.
HTML Document
- salvadordf
- Posts: 4355
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: HTML Document
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.
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.
- salvadordf
- Posts: 4355
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: HTML Document
Please post the user agent string you're using to replicate the issue.
- salvadordf
- Posts: 4355
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: HTML Document
I added this code to the MiniBrowser demo before the GlobalCEFApp.StartMainProcess call :
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.
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)';
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.
- salvadordf
- Posts: 4355
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: HTML Document
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
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
- salvadordf
- Posts: 4355
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: HTML Document
The easiest way would be this :
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.
- 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 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.
- salvadordf
- Posts: 4355
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: HTML Document
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.
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.
- salvadordf
- Posts: 4355
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: HTML Document
You would need to call Frame.GetSource with a ICefStringVisitor parameter but that's exactly what TChromium.RetrieveHTML does.
- salvadordf
- Posts: 4355
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: HTML Document
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
The CEF3 API defines what CEF4Delphi calls ICefRequestHandler.OnResourceLoadComplete with those parameters :
https://bitbucket.org/chromiumembedded/ ... capi.h-222