繁体   English   中英

从Android WebView获取iframe数据

[英]Getting iframe data from Android WebView

我有一个包含iframe的网页:

<div id="confIMG" style="display:block;">
   <iframe id="ifrmy" src="http://www.example.com" style="margin:0;padding:0;border:0;overflow:hidden;height:200px;width:90%;'" scrolling="no">
   </iframe>
   #document
   <!DOCTYPE html>
   <html>
      <head>....</head>
      <body>....</body>
   </html>
</div>

为了获取所有html源,我使用了以下javascript:

javascript:HTMLOUT.processHTML(document.documentElement.outerHTML);

但是,当调用侦听器时,我只会看到:

<div id="confIMG" style="display:block;">
   <iframe id="ifrmy" src="http://www.example.com" style="margin:0;padding:0;border:0;overflow:hidden;height:200px;width:90%;'" scrolling="no">
   </iframe>
</div>

问题是所有iframe文档都丢失了。 我如何才能全部获得?

我还尝试使用JSOUP获取页面。 在这种情况下,我只会得到:

<div id="confIMG" style="display:block;"></div>

PS:我尝试使用Chrome浏览器进行检查。 只有在developer options / developers toolselements使用developer options / developers tools时,才能看到源代码。

如果您不要求JSoup不会自动获取iframe内容,则JSoup不会自动获取它。

首次加载页面后,找到iframe,然后使用Jsoup提取它。

Document doc=...
Element ifrmy = doc.select("#ifrmy").first();

if (ifrmy!=null) {
   Document iframeContent = Jsoup.connect(ifrmy.attr("src")).get();
   // ...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM