android webview点击模拟
我想知道是否可以从网站加载框架,填充文本框,按提交按钮并从该页面获取结果?我需要在后台执行此操作,这样我的网络视图就不会显示,只显示编辑文本和文本视图......
I was wondering if it's possible to load a frame from a website, fill a textbox, press submit button and take the results from that page? I need to do this in background so my webview is never showed, only an edittext and a textview are showed...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能使用 http 请求做你提到的事情吗?
你需要 WebView 做什么?
Can't you do the stuff you mentioned using a http request?
What do you need the WebView for?
您可以使用 httpGet 获取页面,并使用 httpPost 在用户按下提交时发布结果。您所要做的就是确保帖子包含网页期望的数据,并采用其期望的格式。
检查所需内容的一个好方法是使用 Firefox Live HHTP Headers add on (https://addons.mozilla.org/en-US/firefox/addon/live-http-headers/)。
例如,GET 可能是
然后您在 Android 视图中放置编辑文本框和按钮等。当用户按下“提交”时,您会从编辑文本框中获取文本,然后构造一个 POST,如下所示。
You can use httpGet to get the pages and httpPost to post the results when the user presses submit. All you have to do is make sure that the post carries the data that the web page expects, and in the format it expects.
A good way to check what is required is use the Firefox Live HHTP Headers add on (https://addons.mozilla.org/en-US/firefox/addon/live-http-headers/).
For example the GET might be
Then you put up your Android view with edit text boxes and buttons etc. When the user presses Submit, you get the text form the edit text box, and then construct a POST as below.