java 用java构建一个机器人

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5850055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 13:06:40  来源:igfitidea点击:

Building a Bot in java

javabots

提问by ProgramME

I simply want to create an Bot that can run (preferably) on a web-server, and simply 'clicks' on an object of a web page using java.
please refer me to some tutorials that can be of help to me

我只是想创建一个可以在网络服务器上运行(最好)的机器人,并且只需使用 java 来“点击”网页的对象。
请向我推荐一些对我有帮助的教程

采纳答案by George Suaridze

I think you can start from Apache Droids project. They have module for web crawling

我认为你可以从Apache Droids 项目开始。他们有用于网络爬行的模块

回答by JB Nizet

HtmlUnit is a programmable web browser (in Java). See http://htmlunit.sourceforge.net/gettingStarted.html.

HtmlUnit 是一个可编程的网络浏览器(在 Java 中)。请参阅http://htmlunit.sourceforge.net/gettingStarted.html

回答by jefflunt

Since a "click" is basically just a machine requesting a resource, you could do something as simple as:

由于“点击”基本上只是一台请求资源的机器,你可以做一些简单的事情:

clickURL = new BufferedReader(new InputStreamReader(new URL(URLOrFilename).openStream()));

This will open the stream. I don't know if you have to actually read anything (e.g. BufferedReader.readLine()), or if you can immediately close the stream, but that'll do it. Wrap it in a main()method, and you're done.

这将打开流。我不知道您是否必须真正阅读任何内容(例如BufferedReader.readLine()),或者您是否可以立即关闭流,但这会做到。把它包装在一个main()方法中,你就完成了。

You'll need to import the appropriate I/O Java libraries.

您需要导入适当的 I/O Java 库。