Javascript 从Android WebView获取iframe数据
我有一个包含iframe的网页:Javascript 从Android WebView获取iframe数据,javascript,android,html,webview,jsoup,Javascript,Android,Html,Webview,Jsoup,我有一个包含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
<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>
但是,当调用侦听器时,我只看到:
<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 tools
进入tab元素时才能看到源代码。如果您不要求,JSoup将不会自动获取iframe内容
当您第一次加载页面时,找到iframe,然后使用Jsoup获取它
Document doc=...
Element ifrmy = doc.select("#ifrmy").first();
if (ifrmy!=null) {
Document iframeContent = Jsoup.connect(ifrmy.attr("src")).get();
// ...
}
谢谢,但是我发现获取iframe(不是内容而是标签)的唯一方法是使用javascript…当我尝试使用JSOUP获取页面时,我只得到了空DIV!似乎JSOUP只获得了第一个DIVs级别
Document doc=...
Element ifrmy = doc.select("#ifrmy").first();
if (ifrmy!=null) {
Document iframeContent = Jsoup.connect(ifrmy.attr("src")).get();
// ...
}