本文整理汇总了Java中crawlercommons.robots.SimpleRobotRulesParser类的典型用法代码示例。如果您正苦于以下问题:Java SimpleRobotRulesParser类的具体用法?Java SimpleRobotRulesParser怎么用?Java SimpleRobotRulesParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleRobotRulesParser类属于crawlercommons.robots包,在下文中一共展示了SimpleRobotRulesParser类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseRobotsTxt
import crawlercommons.robots.SimpleRobotRulesParser; //导入依赖的package包/类
public static void parseRobotsTxt(String userAgent, String robotsUrl, String robotsTxt, HtmlAnalysisResult result) {
result.setRobotsTxt(robotsTxt);
SimpleRobotRulesParser robotsParser = new SimpleRobotRulesParser();
BaseRobotRules robotRules = robotsParser.parseContent(robotsUrl, robotsTxt.getBytes(), null, userAgent);
result.setRobotsAllowedAll(robotRules.isAllowAll());
result.setRobotsAllowedNone(robotRules.isAllowNone());
result.setRobotsAllowedHome(robotRules.isAllowed("/"));
result.setRobotsSitemaps(robotRules.getSitemaps());
result.setRobotsCrawlDelay(robotRules.getCrawlDelay());
}
示例2: RobotsManagerImpl
import crawlercommons.robots.SimpleRobotRulesParser; //导入依赖的package包/类
public RobotsManagerImpl(BaseHttpFetcher fetcher) {
this(fetcher, new SimpleRobotRulesParser());
}