问题描述
如何检索当前显示在 WebView 中的所有 HTML 内容?
How do I retrieve all HTML content currently displayed in a WebView?
我找到了 WebView.loadData()
但我找不到相反的等价物(例如 WebView.getData())
I found WebView.loadData()
but I couldn't find the opposite equivalent (e.g. WebView.getData())
请注意,我有兴趣检索我无法控制的网页的数据(即,我无法将 Javascript 函数注入这些页面,因此它会在 WebView 中调用 Javascript 接口).
Please note that I am interested in retrieving that data for web pages that I have no control over (i.e. I cannot inject a Javascript function into those pages, so that that it would call a Javascript interface in WebView).
推荐答案
很遗憾,没有简单的方法可以做到这一点.
Unfortunately there is not easy way to do this.
您可以向与 WebView 相同的页面发出 HttpRequest 并获得响应.
You could just make a HttpRequest to the same page as your WebView and get the response.
这篇关于如何从 WebView 检索 HTML 内容(作为字符串)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!