From cf6d56630ba7cab29b2be0262e49ea27e8dff668 Mon Sep 17 00:00:00 2001 From: Songrui <1778280163@qq.com> Date: Fri, 29 May 2026 00:21:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20'java-cli/src/main/java/co?= =?UTF-8?q?m/example/datacollect/command/CrawlCommand.java'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datacollect/command/CrawlCommand.java | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 java-cli/src/main/java/com/example/datacollect/command/CrawlCommand.java diff --git a/java-cli/src/main/java/com/example/datacollect/command/CrawlCommand.java b/java-cli/src/main/java/com/example/datacollect/command/CrawlCommand.java deleted file mode 100644 index 59a2ef6..0000000 --- a/java-cli/src/main/java/com/example/datacollect/command/CrawlCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.example.datacollect.command; - -import com.example.datacollect.model.Article; -import com.example.datacollect.view.ConsoleView; -import java.util.List; -import java.util.regex.Pattern; - -public class CrawlCommand implements Command { - private static final String URL_REGEX = "^(https?|ftp)://[\\w\\-]+(\\.[\\w\\-]+)+([:\\d+])?(\\/[^\\s]*)?$"; - private static final Pattern URL_PATTERN = Pattern.compile(URL_REGEX); - - private final ConsoleView view; - - public CrawlCommand(ConsoleView view) { - this.view = view; - } - - @Override - public String getName() { - return "crawl"; - } - - @Override - public void execute(String[] args, List
articles) { - if (args.length < 2) { - view.printError("Usage: crawl "); - return; - } - - String url = args[1]; - if (!isValidUrl(url)) { - view.printError("Invalid URL format: " + url); - view.printInfo("Please enter a valid URL (e.g., http://example.com)"); - return; - } - - view.printInfo("Stub: would crawl " + url); - } - - private boolean isValidUrl(String url) { - if (url == null || url.isEmpty()) { - return false; - } - return URL_PATTERN.matcher(url).matches(); - } -}