0

I want to get the HTML source of the iframe present on the webpage. I am using chromedp package with Go. How to handle the iframes with chromedp package? The documentation is very less so couldn't find a way.

Links:

chromedp

Google-doc to get more details of my task.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
yogesh_desai
  • 449
  • 9
  • 21
  • What have you tried so far? Does it select with XPath like `//iframe`? Could you show you code to better understand the problem? – Eugene Lisitsky Sep 13 '17 at 07:25
  • @EugeneLisitsky: Please check the [file](https://gist.github.com/yogesh-desai/cfb484cd0349fe18cb8e048f38616a6c) for my code so far. I am able to get "webyclip-widget-3" iframe with its "ID". But unable to get the complete HTML under it. "Inspect" element shows the videos and "img" tags. I want that "img" tags to extract the videos links. – yogesh_desai Sep 13 '17 at 08:23

1 Answers1

1

After many attempts, Finally, I found the way and solved my query. You can check my GitHub repository for this query. Thank you. To get the iframe contents we can use Javascript. Way to do it with chromedp is as below,

cdp.EvaluateAsDevTools("document.getElementById('IFRAME-ID').contentWindow.document.body.outerHTML;", RESULT-BUFFER),
yogesh_desai
  • 449
  • 9
  • 21
  • how to handle javascript alert and get the text inside it. I notice there is `Page.javascriptDialogOpening` in the method – Salis Sep 24 '19 at 17:33
  • I get this error: Error: Blocked a frame with origin "https://www.someSite.com" from accessing a cross-origin frame. – Maxim Yefremov Dec 01 '21 at 11:33