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.
34 lines
948 B
34 lines
948 B
import java.util.List;
|
|
|
|
public class AnalyzeCommand2 implements Command2 {
|
|
private final StrategyFactory2 factory;
|
|
|
|
public AnalyzeCommand2(StrategyFactory2 factory) {
|
|
this.factory = factory;
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "analyze";
|
|
}
|
|
|
|
@Override
|
|
public void execute(String[] args, List<Article2> articles) {
|
|
if (args == null || args.length == 0) {
|
|
System.out.println("格式:analyze 网址");
|
|
return;
|
|
}
|
|
|
|
String url = args[0];
|
|
CrawlStrategy2 strategy = factory.getMatchStrategy(url);
|
|
|
|
System.out.println("===== 分析结果 =====");
|
|
if (strategy != null) {
|
|
System.out.println("链接:" + url);
|
|
System.out.println("状态:可以解析 ✅");
|
|
} else {
|
|
System.out.println("链接:" + url);
|
|
System.out.println("状态:不支持 ❌");
|
|
}
|
|
}
|
|
}
|