novelsquare-downloader
v1.0.0
Published
Download novels from novelsquare.blog as Markdown files
Downloads
7
Maintainers
Readme
NovelSquare Downloader
命令行工具,用于从 novelsquare.blog 下载小说并导出为 Markdown 格式。
功能特点
- 🔐 支持邮箱和 Google 登录
- 📚 批量下载小说章节
- 📝 导出为 Markdown 格式
- ⚡ 自动限速(1-2秒/章节)
- 🎯 支持指定章节范围
- 💾 Cookie 持久化,登录一次永久使用
安装
方式一:从 npm 安装(推荐)
# 全局安装
npm install -g novelsquare-downloader
# 或使用 npx 运行(无需安装)
npx novelsquare-downloader download <slug>方式二:从源码安装
# 克隆仓库
git clone https://github.com/bluetent/novelsquare-downloader.git
cd novelsquare-downloader
# 安装依赖
npm install
# 构建
npm run build
# 全局安装(可选)
npm link使用方法
1. 首次登录
# 如果全局安装了
novelsquare login
# 或者直接运行
npm run dev -- login这会打开一个浏览器窗口,你可以在其中手动登录(支持邮箱或 Google 登录)。登录完成后按回车,程序会自动保存登录信息。
2. 下载小说
# 基本用法
novelsquare download alphas-regret-the-luna-is-secret-heiress
# 指定输出路径
novelsquare download <slug> -o ./my-novels/
# 下载指定章节范围
novelsquare download <slug> --start 10 --end 50
# 匿名下载(不登录)
novelsquare download <slug> --no-login3. 检查登录状态
novelsquare status参数说明
download 命令
<slug>- 小说的 URL slug(必需)- 例如:
alphas-regret-the-luna-is-secret-heiress - 从小说 URL 中获取:
https://novelsquare.blog/novel/alphas-regret-the-luna-is-secret-heiress
- 例如:
-o, --output <path>- 输出路径(可选)- 可以是文件路径:
-o my-novel.md - 也可以是目录:
-o ./novels/
- 可以是文件路径:
--start <number>- 起始章节号(默认:1)--end <number>- 结束章节号(默认:全部)--no-login- 匿名下载(不使用登录信息)
输出格式
下载的小说会保存为单个 Markdown 文件,包含:
- 小说标题和作者
- 完整目录(可点击跳转)
- 所有章节内容
示例:
# Alpha's Regret: The Luna Is Secret Heiress
**作者**: FindNovel.net
**章节数**: 50
---
## 目录
1. [Chapter 1](#chapter-1)
2. [Chapter 2](#chapter-2)
...
---
## Chapter 1
{章节内容}
---配置
登录信息保存在:~/.novelsquare-cookies.json
可以在 src/utils/config.ts 中调整:
- 下载延迟时间
- Cookie 保存路径
开发
# 安装依赖
npm install
# 开发模式运行
npm run dev -- <command>
# 构建
npm run build
# 运行已构建的版本
node dist/cli.js <command>故障排除
登录失败
- 确保在浏览器窗口中完全登录后再按回车
- 检查
~/.novelsquare-cookies.json是否存在
下载内容为空
- 确认小说 slug 正确
- 尝试手动访问章节 URL 确认是否需要登录
- 网站结构可能已更改,需要更新 CSS 选择器
章节 404
- 某些小说可能章节不连续,程序会自动跳过不存在的章节
技术栈
- Node.js + TypeScript
- Puppeteer(浏览器自动化)
- Commander.js(CLI 框架)
License
MIT
免责声明
本工具仅供个人学习和研究使用。请遵守 novelsquare.blog 的服务条款。
