使用UADetector检测机器人

使用UADetector检测机器人

问题描述:

我正在测试Java用户代理检测器API http://uadetector.sourceforge.net 。根据项目主页,API可以检测机器人。但是查看文档并使用API​​我无法找到机器人的参考。

I am testing Java user-agent detector API http://uadetector.sourceforge.net. According to the project home page the API can detect robots. But looking at the docs and playing around with the API I can't find reference to Robots.

任何人都可以指引我走向正确的方向吗?

Can anyone direct me to the right direction?

你可以这样做:

UserAgentStringParser parser = UADetectorServiceFactory.getOnlineUpdatingParser();
ReadableUserAgent agent = parser.parse(request.getHeader("User-Agent"));
UserAgentType type = agent.getUserAgentType();  // this can be ROBOT, BROWSER, etc.

有关更多信息,请查看此网站这个例子

For more information, check this site and this example.