|
| 1 | +# 数据保存指南 / Data Storage Guide |
| 2 | + |
| 3 | +[English](#english) | [中文](#中文) |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 中文 |
| 8 | + |
| 9 | +### 💾 数据保存 |
| 10 | + |
| 11 | +MediaCrawler 支持多种数据存储方式,您可以根据需求选择最适合的方案: |
| 12 | + |
| 13 | +#### 存储方式 |
| 14 | + |
| 15 | +- **CSV 文件**:支持保存到 CSV 中(`data/` 目录下) |
| 16 | +- **JSON 文件**:支持保存到 JSON 中(`data/` 目录下) |
| 17 | +- **Excel 文件**:支持保存到格式化的 Excel 文件(`data/` 目录下)✨ 新功能 |
| 18 | + - 多工作表支持(内容、评论、创作者) |
| 19 | + - 专业格式化(标题样式、自动列宽、边框) |
| 20 | + - 易于分析和分享 |
| 21 | +- **数据库存储** |
| 22 | + - 使用参数 `--init_db` 进行数据库初始化(使用`--init_db`时不需要携带其他optional) |
| 23 | + - **SQLite 数据库**:轻量级数据库,无需服务器,适合个人使用(推荐) |
| 24 | + 1. 初始化:`--init_db sqlite` |
| 25 | + 2. 数据存储:`--save_data_option sqlite` |
| 26 | + - **MySQL 数据库**:支持关系型数据库 MySQL 中保存(需要提前创建数据库) |
| 27 | + 1. 初始化:`--init_db mysql` |
| 28 | + 2. 数据存储:`--save_data_option db`(db 参数为兼容历史更新保留) |
| 29 | + |
| 30 | +#### 使用示例 |
| 31 | + |
| 32 | +```shell |
| 33 | +# 使用 Excel 存储数据(推荐用于数据分析)✨ 新功能 |
| 34 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option excel |
| 35 | + |
| 36 | +# 初始化 SQLite 数据库 |
| 37 | +uv run main.py --init_db sqlite |
| 38 | +# 使用 SQLite 存储数据 |
| 39 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option sqlite |
| 40 | +``` |
| 41 | + |
| 42 | +```shell |
| 43 | +# 初始化 MySQL 数据库 |
| 44 | +uv run main.py --init_db mysql |
| 45 | +# 使用 MySQL 存储数据(为适配历史更新,db参数进行沿用) |
| 46 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option db |
| 47 | +``` |
| 48 | + |
| 49 | +```shell |
| 50 | +# 使用 CSV 存储数据 |
| 51 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option csv |
| 52 | + |
| 53 | +# 使用 JSON 存储数据 |
| 54 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option json |
| 55 | +``` |
| 56 | + |
| 57 | +#### 详细文档 |
| 58 | + |
| 59 | +- **Excel 导出详细指南**:查看 [Excel 导出指南](excel_export_guide.md) |
| 60 | +- **数据库配置**:参考 [常见问题](常见问题.md) |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## English |
| 65 | + |
| 66 | +### 💾 Data Storage |
| 67 | + |
| 68 | +MediaCrawler supports multiple data storage methods. Choose the one that best fits your needs: |
| 69 | + |
| 70 | +#### Storage Options |
| 71 | + |
| 72 | +- **CSV Files**: Supports saving to CSV (under `data/` directory) |
| 73 | +- **JSON Files**: Supports saving to JSON (under `data/` directory) |
| 74 | +- **Excel Files**: Supports saving to formatted Excel files (under `data/` directory) ✨ New Feature |
| 75 | + - Multi-sheet support (Contents, Comments, Creators) |
| 76 | + - Professional formatting (styled headers, auto-width columns, borders) |
| 77 | + - Easy to analyze and share |
| 78 | +- **Database Storage** |
| 79 | + - Use the `--init_db` parameter for database initialization (when using `--init_db`, no other optional arguments are needed) |
| 80 | + - **SQLite Database**: Lightweight database, no server required, suitable for personal use (recommended) |
| 81 | + 1. Initialization: `--init_db sqlite` |
| 82 | + 2. Data Storage: `--save_data_option sqlite` |
| 83 | + - **MySQL Database**: Supports saving to relational database MySQL (database needs to be created in advance) |
| 84 | + 1. Initialization: `--init_db mysql` |
| 85 | + 2. Data Storage: `--save_data_option db` (the db parameter is retained for compatibility with historical updates) |
| 86 | + |
| 87 | +#### Usage Examples |
| 88 | + |
| 89 | +```shell |
| 90 | +# Use Excel to store data (recommended for data analysis) ✨ New Feature |
| 91 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option excel |
| 92 | + |
| 93 | +# Initialize SQLite database |
| 94 | +uv run main.py --init_db sqlite |
| 95 | +# Use SQLite to store data |
| 96 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option sqlite |
| 97 | +``` |
| 98 | + |
| 99 | +```shell |
| 100 | +# Initialize MySQL database |
| 101 | +uv run main.py --init_db mysql |
| 102 | +# Use MySQL to store data (the db parameter is retained for compatibility with historical updates) |
| 103 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option db |
| 104 | +``` |
| 105 | + |
| 106 | +```shell |
| 107 | +# Use CSV to store data |
| 108 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option csv |
| 109 | + |
| 110 | +# Use JSON to store data |
| 111 | +uv run main.py --platform xhs --lt qrcode --type search --save_data_option json |
| 112 | +``` |
| 113 | + |
| 114 | +#### Detailed Documentation |
| 115 | + |
| 116 | +- **Excel Export Guide**: See [Excel Export Guide](excel_export_guide.md) |
| 117 | +- **Database Configuration**: Refer to [FAQ](常见问题.md) |
0 commit comments