Using UADetector To detect Robots

筅森魡賤 提交于 2019-12-22 06:37:35

问题


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?


回答1:


You can do it like this:

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.



来源:https://stackoverflow.com/questions/17790577/using-uadetector-to-detect-robots

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!