使用UADetector检测机器人 [英] Using UADetector To detect Robots

查看:193
本文介绍了使用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.

这篇关于使用UADetector检测机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆