如何在 Android 中的网页上填写表单?
您将如何在 Android 程序中填写网页(不受我控制)上的表单?
我想编写一个小android程序来自动与其他人编写的网站进行交互,但我无法更改。它没有发布的 API。所以过程是:
- 获取带有表单的网页(例如登录页面)
- 解析它(例如在页面上找到用户名、密码框)
- 进行一些处理(例如从数据库中获取用户名和密码)
- 提交返回并获取结果(例如模拟用户点击登录)
- 重复...
这是第 4 步,我需要帮助。如果我不使用 Android,我会使用像 libcurl(对于 python)或 apache httpclient(对于普通 java)这样的库,或者我会与网络浏览器进行一些 DOM 交互。您建议为 Android 做什么?您推荐的标准库中是否内置了某些内容?
我是一位经验丰富的 Java 程序员,但我在 Android 中写的只是 hello world,如果这会影响您的答案。
How would you fill in a form on a webpage (not under my control) in an Android program?
I want to write a little android program to automate interacting with a website that someone else has written and I can't change. It has no published API. So the process is:
- Fetch the web page with a form on it (eg a login page)
- Parse it (eg find the username, password box on the page)
- Do some processing (eg fetch a username and password from a database)
- Submit the form back and get the result (eg simulate the user hitting login)
- Repeat ...
It is step 4 I'd like the help with. If I wasn't using Android I'd use a library library like libcurl (for python) or apache httpclient (for normal java), or I'd do some DOM interaction with a webbrowser. What would you recommend doing for android? Is there something built into the standard libraries you'd recommend?
I'm a pretty experienced Java programmer but all I've written in Android is hello world, if that affects your answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Apache httpclient 内置于标准 Android 中图书馆。使用那里的普通代码 - HttpGet 和HttpPost
这也能提供帮助与步骤 1 一样。
Doh,在求助于 Stack Overflow 之前应该先用 google 搜索一下。
Apache httpclient is built into the standard Android libraries. Use the normal code there - HttpGet and HttpPost
This will also be able to help with step 1 as well.
Doh, should have googled for a bit longer before resorting to Stack Overflow.