Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在测试 Java 用户代理检测器 API http://uadetector.sourceforge.net。根据项目主页,API 可以检测机器人。但是查看文档并使用 API 我找不到对机器人的参考。
谁能指引我正确的方向?
你可以这样做:
UserAgentStringParser parser = UADetectorServiceFactory.getOnlineUpdatingParser(); ReadableUserAgent agent = parser.parse(request.getHeader("User-Agent")); UserAgentType type = agent.getUserAgentType(); // this can be ROBOT, BROWSER, etc.
有关更多信息,请查看此站点和此示例。