如何从 Java 小程序(浏览器内)提取数据
好吧,好吧,我们开始...
我们有一个在常规浏览器(ff4+ 或 ie5+)上运行的 java 小程序。
我无法访问 java 代码/servlet。甚至也不到服务器。
我需要从此小程序发送/检索数据。这意味着我必须通过单击按钮并填写表单的文本框来模拟用户,并且还返回文本框中的数据(在服务器响应之后)。
因此可以使用的技术有C、VB、.NET(主要是webbrowser对象)、PHP(cUrl可用)、JavaScript、使用Fiddler嗅探浏览器/服务器通信。
我们确实需要这个。但如果那是不可能的,那么我们可能也必须知道。 这些数据归我公司所有,因此不构成任何版权。
另外,我对非传统解决方案持开放态度,例如将 html 保存为图像,然后使用某些 OCR 软件检索数据......
好吧,因此任何建议或指示将不胜感激。
谢谢
保罗·布埃诺。
Well, well, here we go...
We have a java applet running on a regular browser (ff4+ or ie5+).
I do NOT have access to the java code / servlet. Nor even to the server.
I NEED to send/retrieve data from this applet. This means i must emulate an user onto it by clicking buttons and filling form's textboxes and also return data (after server response) wich ll be inside textboxes.
So the technologies avaibles to be used are C, VB, .NET (webbrowser object mainly), PHP (cUrl avaible), JavaScript, Sniffing the browser/server communication using Fiddler.
We really need this. But if thats impossible so we may have to know also.
The data is owned by my company so no copyrigth is inflicted.
Also i'm open to non traditional solution such as saving the html as an image and then retrieve the data using some OCR software...
Well so any suggestion or pointing directions would be gratefully appreciated.
Thx
Paulo Bueno.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
必须模拟用户浏览会带来问题,如果可行的话,我会建议替代路线。这些是我将采取的步骤:
Having to emulate a user browsing is wrought with problems and i would suggest an alternate route, if its feasible. These are the steps I would take:
您可以使用 JRE 中附带的“appletviewer”在没有浏览器的情况下运行任何小程序。通过这种方式,可以通过 http://code.google.com 读取和发送虚假输入,但不切实际/p/windowlicker/ 控制 SWING GUI。
但在可以访问代码的常规浏览器环境中,您宁愿这样做:
在对象标记中使用“scriptable”和“mayscript”属性/元素。标准浏览器 JRE 包含一个“plugin.jar”,其中包含完成此工作所需的函数。这个接口让 Java-Applet 代码与 Javascript 进行反之亦然的通信,从中你可以做任何你想做的事情(即 ajax 请求)
这个主题相当复杂,所以看看 google 告诉我们的内容:
http://www.htmlcodetutorial.com/applets/_APPLET_MAYSCRIPT.html
http://www.raditha.com/java/javascript.php
使用此接口是真的很痛苦,所以我建议在你的小程序中实现 HTTPRequests 来告诉 PHP 服务器你想告诉它的任何信息。
问候,
迈克尔
You can run any applet without a browser using the "appletviewer" that is shipped in a JRE. This way it is possible but not practicable to read and send fake input with http://code.google.com/p/windowlicker/ to control the SWING GUI.
But within a regular browser environment with access to the code you would rather do this:
using the "scriptable" and "mayscript" attributes/elements in your object tag. standard browser JREs include a "plugin.jar" that contains the needed function to do this job. This interface lets Java-Applet code communicate vice versa to Javascript, from wich you can do whatever you want (i.e. ajax request)
this topic is rather complex, so check out what google tells us:
http://www.htmlcodetutorial.com/applets/_APPLET_MAYSCRIPT.html
http://www.raditha.com/java/javascript.php
Using this interface is a real pain, so i suggest to implement HTTPRequests within your applet to tell the PHP server whatever you want to tell it.
regards,
Michael
嗯……这是很不寻常的情况。如果您有该小程序,当然,您应该有权访问其 src 文件进行修改:)
无论如何,要“模拟”用户,您可以使用 Robot 对象但它仍然会要求你修改小程序代码以使其支持一些附加功能...据我记得,JS等无法从外部命令控制Java小程序,除非小程序确实包含JS支持的网页交互功能。但你还是说你。 无法访问该小程序 src,因此没有任何信息该小程序是否支持 netscape.javascript 以及它如何支持它,所以还不清楚...所以我必须问你吗有这个小程序的文档吗?
围绕问题文本并回到问题标题本身,上面写着
我可能会这么说
要从 Java Applet 中提取数据,您可以使用支持 Java Applet 和 JS 交互的 netscape lib 示例, 文档。在这种情况下这是最好的方法
祝你好运
Emm... It is quite unusual situation. If you have the applet, of course, you should have access to its src files to modify :)
Anyway, to "emulate" user you can use the Robot object but still it will demand you to modify the applet code to make it support some additional functionality... As I can remember, JS etc cannot control Java Applet from the outside commands unless the applet does contain JS supported functionality for web page interaction... But still you say you don't have any access to the applet src so there is no information does the applet support netscape.javascript or not and how it support it so it is quite unclear... So I must ask do you have any docs of this applet?
Comming around the question text and getting back to the question title itself which says
I may suppose to say that
To extract data from Java Applet you can use netscape lib which supports Java Applet and JS interaction example, docs. That is the most optimal way in this case
Good luck
反编译/更改/再次编译小程序可能不会太困难,除非它被混淆了。
我用的是杰德。
https://stackoverflow.com/questions/31353/is-jad-the-best- java反编译器
Might not be too difficult to de-compile/change/compile again the applet unless it is obfuscated.
I use JAD.
https://stackoverflow.com/questions/31353/is-jad-the-best-java-decompiler
如果您必须通过与 java 小程序交互来获取数据而不是对其进行逆向工程,请查看 FEST(Fixtures for简单的软件测试)。 FEST 旨在通过模拟用户交互来测试 Java Swing GUI,但您也可以轻松地使用它来自动化您的小程序。
查看测试小程序上的文档页面以开始使用。
If you must get your data by interacting with the java applet instead of reverse engineering it, check out FEST (Fixtures for Easy Software Testing). FEST is designed for testing Java Swing GUIs by simulating user interaction, but you can easily use it to automate your applet as well.
Check out the documentation page on testing applets to get started.