Files
nanocode/libraryofshortstories-scraper/README.md
T
Ubuntu 32b43f85bd a
2026-07-03 16:58:28 +08:00

102 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Library of Short Stories 下载器
从 https://www.libraryofshortstories.com 下载英语短篇故事。
## 功能特性
- ✅ **API 直接获取**: 无需浏览器,直接调用网站 API
- ✅ **断点续传**: 中断后自动从上次位置继续
- ✅ **后台运行**: 支持后台下载,不影响其他操作
- ✅ **7秒间隔**: 礼貌下载,避免被封
- ✅ **元数据保存**: 保存作者、年份、类型等信息
- ✅ **纯文本输出**: 去除 HTML 标签,干净阅读
## 快速开始
### 1. 获取故事索引(Phase 1)
```bash
./start.sh fetch
```
这会从 API 获取最多 1000 个故事的链接,保存到 `config/stories_index.json`
### 2. 下载故事(Phase 2)
**前台模式**(适合少量下载):
```bash
./start.sh download
```
**后台模式**(推荐,适合大量下载):
```bash
./start.sh download-bg
```
### 3. 查看状态
```bash
./start.sh status
```
### 4. 查看日志
```bash
./start.sh log # 查看最近日志
tail -f logs/download.log # 实时跟踪
```
### 5. 停止下载
```bash
./start.sh stop
```
## 存储结构
```
/home/ubuntu/media/libraryofshortstories/
├── the-adventure-of-the-red-circle/
│ ├── content.txt # 故事正文
│ └── metadata.md # 元数据
├── the-1000000-bank-note/
│ ├── content.txt
│ └── metadata.md
└── ...
```
## 索引文件格式
`config/stories_index.json`:
```json
{
"fetch_date": "2026-03-27T10:00:00",
"total_available": 1500,
"max_limit": 1000,
"stories": [
{
"id": 1,
"title": "The £1,000,000 Bank-Note",
"author": "Mark Twain",
"code": "the-1000000-bank-note",
"url": "https://www.libraryofshortstories.com/onlinereader/the-1000000-bank-note",
"status": "downloaded",
"download_date": "2026-03-27T10:05:00"
}
]
}
```
## 技术细节
- **下载间隔**: 7 秒
- **超时设置**: 30 秒
- **重试机制**: 失败标记为 failed,下次运行会重试
- **并发数**: 单线程,避免被封
## 注意事项
1. 下载约 1000 个故事需要约 **2 小时** (1000 × 7秒)
2. 建议首次使用后台模式 `./start.sh download-bg`
3. 可以安全中断 (Ctrl+C 或 `./start.sh stop`),进度会自动保存