How to handle iframes on a webpage

huangapple go评论92阅读模式
英文:

How to handle iframes on a webpage

问题

我想获取位于网页上的iframe的HTML源代码。我正在使用Go语言的chromedp包。如何使用chromedp包处理iframes?由于文档很少,所以找不到方法。

链接:

chromedp

Google文档以获取有关我的任务的更多详细信息。

英文:

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.

答案1

得分: 1

经过多次尝试,最终我找到了方法并解决了我的问题。你可以查看我的GitHub存储库以获取此查询的详细信息。谢谢。
要获取iframe的内容,我们可以使用JavaScript。使用chromedp的方法如下:

cdp.EvaluateAsDevTools("document.getElementById('IFRAME-ID').contentWindow.document.body.outerHTML;", RESULT-BUFFER),
英文:

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),

huangapple
  • 本文由 发表于 2017年9月12日 14:30:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/46169407.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定