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.
 
 

41 lines
1018 B

package com.crawler.command;
import com.crawler.controller.CrawlerController;
import com.crawler.view.ConsoleView;
public class CrawlCommand implements Command {
private final CrawlerController controller;
private final ConsoleView view;
public CrawlCommand(CrawlerController controller, ConsoleView view) {
this.controller = controller;
this.view = view;
}
@Override
public void execute(String[] args) {
if (args.length < 1) {
view.displayError("Usage: crawl <url> [strategy]");
return;
}
String url = args[0];
String strategy = args.length > 1 ? args[1] : "jsoup";
try {
controller.crawl(url, strategy);
} catch (Exception e) {
view.displayError("Crawl failed: " + e.getMessage());
}
}
@Override
public String getCommandName() {
return "crawl";
}
@Override
public String getDescription() {
return "Crawl a website";
}
}