如何从 WebView 检索 HTML 内容(作为字符串) [英] How to retrieve HTML content from WebView (as a string)

查看:23
本文介绍了如何从 WebView 检索 HTML 内容(作为字符串)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检索当前显示在 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 的网页内容?

您可以向与 WebView 相同的页面发出 HttpRequest 并获得响应.

You could just make a HttpRequest to the same page as your WebView and get the response.

这篇关于如何从 WebView 检索 HTML 内容(作为字符串)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆