Java桌面应用程序弹出网站验证码
希望有人能指出我正确的方向。
我对 Java 很陌生,想要构建一个小型应用程序来练习等。
无论如何,我想在网站上填写表格并获取数据。我查看了 HtmlUnit 和 HtmlComponents,认为我已经涵盖了大部分设计。
我不明白的是该网站只有一个验证码,我希望我的桌面应用程序弹出一个窗口,我可以在其中输入验证码(手动,我不是创建机器人)。
这在Java中可能吗?
Hoping someone can point me in the right direction.
I'm quite new to Java and wanting to build a small app to practice etc.
Anyway I want to fill out a form on a site and grab the data. I have had a look at HtmlUnit and HtmlComponents and think I have most of the design covered.
Something I can't figure out is the site has a single captcha and I want my desktop app to popup a window where I would enter the captcha (manually, I'm not creating a bot).
Is this possible in Java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是可能的,事实上 JDownloader 正在这样做。它是开源的,因此您可以查看其代码。
It's possible and in fact JDownloader is doing it. It's open source, so you can take a look to its code.
正如之前提到的,JDownloader 很好地完成了这项技术。您提到来源相当难以理解,所以我将解释人们会做什么的基础知识。
首先,您需要创建将填写表单的代码,一旦表单命中验证码,它就会打开一个框架,其中有一个图像位置(这将是验证码图像)、一个文本字段和一个提交按钮。提交按钮应该具有将文本从文本字段发送到表单中的验证码文本字段的操作。
摘要:
1:创建将填写表单的类
2:到达验证码后,使其打开“验证码解决框架”
3:填写文本字段并创建一个在按钮会将您的字符串发送到表单 4 中的文本字段
:如果您不正确地填写了验证码,则抛出某种 catch
附带说明,如果使用 Groovy(或脚本语言)完成此操作会更容易且相当简洁)而不是Java。
As mentioned before JDownloader does this technique quite well. You mentioned the source is rather difficult to understand, so I'll explain the basics of what one would do.
First you would want to create your code that will fill in the form, once the form hits the captcha have it open up a frame that has a spot for an image (which will be the captcha image), a textfield, and a submit button. The submit button should have an action that will send the text from the textfield to the captcha text field in the form.
Summary:
1: Create you class that will fill in the form
2: Once it gets to the capthca make it open your 'captcha solving frame'
3: Fill in the text field and create an actionPerformed on the button that will send your string to the textfield in the form
4: Throw in some sort of catch in case you improperly fill in the captcha
On a side note, this would be easier and considerably less verbose if done with Groovy (or a scripting language) rather than Java.