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.
 
 
Luojiale 3557013fe8 Add w5 to w11 projects: shape inheritance, animal interface, exception handling, generics, maven project, repository with analyze command, exception hierarchy with retry 3 weeks ago
..
src/main/java/com/crawler Add w5 to w11 projects: shape inheritance, animal interface, exception handling, generics, maven project, repository with analyze command, exception hierarchy with retry 3 weeks ago
README.md Add w5 to w11 projects: shape inheritance, animal interface, exception handling, generics, maven project, repository with analyze command, exception hierarchy with retry 3 weeks ago
RUNNING.md Add w5 to w11 projects: shape inheritance, animal interface, exception handling, generics, maven project, repository with analyze command, exception hierarchy with retry 3 weeks ago
pom.xml Add w5 to w11 projects: shape inheritance, animal interface, exception handling, generics, maven project, repository with analyze command, exception hierarchy with retry 3 weeks ago
test.bat Add w5 to w11 projects: shape inheritance, animal interface, exception handling, generics, maven project, repository with analyze command, exception hierarchy with retry 3 weeks ago

README.md

文章爬虫系统

这是一个使用 Maven 创建的 Java 项目,实现了命令行界面的文章爬虫系统。

项目结构

w9/
├── pom.xml                                    # Maven 配置文件
├── README.md                                  # 项目文档
└── src/
    └── main/
        └── java/
            └── com/
                └── crawler/
                    ├── Main.java              # 主程序入口
                    ├── model/
                    │   └── Article.java       # 文章数据模型
                    ├── view/
                    │   └── ConsoleView.java   # 控制台视图
                    ├── command/
                    │   ├── Command.java       # 命令接口
                    │   ├── HelpCommand.java   # 帮助命令
                    │   ├── ListCommand.java   # 列表命令
                    │   ├── CrawlCommand.java  # 爬取命令
                    │   └── ExitCommand.java   # 退出命令
                    └── controller/
                        └── CommandController.java  # 命令控制器

功能特性

已实现的命令

  1. help - 显示帮助信息
  2. list - 显示已抓取的文章列表
  3. crawl - 开始抓取文章(目前为存根实现)
  4. exit - 退出程序

项目架构

  • model: 数据模型层 - 定义文章数据结构
  • view: 视图层 - 处理控制台输出
  • command: 命令层 - 实现各种命令
  • controller: 控制层 - 管理命令执行

编译运行

编译项目

cd w9
mvn clean compile

运行项目

mvn exec:java

或者先打包再运行:

mvn package
java -jar target/crawler-app-1.0-SNAPSHOT.jar

使用示例

================================================
      欢迎使用文章爬虫系统
================================================

可用命令:
  help  - 显示帮助信息
  list  - 显示已抓取的文章列表
  crawl - 开始抓取文章
  exit  - 退出程序

请输入命令 > help

可用命令:
  help  - 显示帮助信息
  list  - 显示已抓取的文章列表
  crawl - 开始抓取文章
  exit  - 退出程序

请输入命令 > crawl

正在开始抓取文章...
抓取完成,共抓取了 3 篇文章

请输入命令 > list

已抓取的文章列表:
----------------------------------------
1. 示例文章1
   URL: https://example.com/article1
----------------------------------------
2. 示例文章2
   URL: https://example.com/article2
----------------------------------------
3. 示例文章3
   URL: https://example.com/article3
----------------------------------------
共 3 篇文章

请输入命令 > exit

感谢使用,再见!

技术栈

  • Java 8
  • Maven 3.x

扩展功能

当前 crawl 命令是存根实现,可以扩展为:

  1. 连接实际的文章网站
  2. 解析 HTML 内容
  3. 提取文章标题、URL、内容等
  4. 保存到数据库或文件