Hi,
When i use the RetrieveHtml method, it won't get the source of an Iframe of the page. How can i get the source of an specific Iframe inside the page ?
Thanks
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.
Get source from an Iframe
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Get source from an Iframe
Hi,
There are 3 overloaded versions of TChromium.RetrieveHTML :
You can call TChromium.GetFrameNames or TChromium.GetFrameIdentifiers to get the frame names or identifiers and then call TChromium.RetrieveHTML with one of those names or identifiers to get the HTML code from that frame.
There are 3 overloaded versions of TChromium.RetrieveHTML :
- TChromium.RetrieveHTML(const aFrameName : ustring = '');
- TChromium.RetrieveHTML(const aFrame : ICefFrame);
- TChromium.RetrieveHTML(const aFrameIdentifier : int64);
You can call TChromium.GetFrameNames or TChromium.GetFrameIdentifiers to get the frame names or identifiers and then call TChromium.RetrieveHTML with one of those names or identifiers to get the HTML code from that frame.
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Get source from an Iframe
Thank you very much for answering Salvador !
Any examples how to use GetFrameNames ? It has a TStrings parameter, but this is an abstract class...
Any examples how to use GetFrameNames ? It has a TStrings parameter, but this is an abstract class...
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Get source from an Iframe
Create a TStringList and use it as the aFrameNames parameter. If necessary cast it as TStrings :
Code: Select all
Chromium1.GetFrameNames(TStrings(MyStringList));
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Get source from an Iframe
Thank you, this worked. Is there a way to get the frame html source by its id in DOM ?
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Get source from an Iframe
As far as I know, you can only search by the DOM name. The "identifiers" have nothing to do with the "id" DOM attribute.
Perhaps you can set the focus on some element inside the desired frame and call TChromium.Browser.FocusedFrame
Perhaps you can set the focus on some element inside the desired frame and call TChromium.Browser.FocusedFrame
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Get source from an Iframe
Ok, no problem, the other method worked ! Thanks ! 
