You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

import java.util.List;
import java.util.logging.Logger;
public class AnalyzeCommand11 implements Command11 {
private static final Logger logger = Logger.getLogger(AnalyzeCommand11.class.getName());
private final StrategyFactory11 factory;
public AnalyzeCommand11(StrategyFactory11 factory) {
this.factory = factory;
}
@Override
public String getName() {
return "analyze";
}
@Override
public void execute(String[] args, List<Article11> articles) {
if (args == null || args.length == 0) {
logger.warning("analyze 命令未传入URL参数");
System.out.println("用法:analyze 网址");
return;
}
String url = args[0];
logger.info("开始分析链接:" + url);
CrawlStrategy11 strategy = factory.getMatchStrategy(url);
System.out.println("===== 链接分析结果 =====");
if (strategy != null) {
logger.info("链接 " + url + " 匹配到对应爬取策略");
System.out.println("链接:" + url);
System.out.println("状态:支持解析 ✅");
} else {
logger.warning("链接 " + url + " 未匹配到任何策略");
System.out.println("链接:" + url);
System.out.println("状态:不支持解析 ❌");
}
}
}