Files
kenney-asset-scrapper/README.md
2025-04-22 09:11:40 +08:00

112 lines
3.2 KiB
Markdown
Raw Permalink 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.
# 🧲 Kenney Asset Scrapper
一个为开发者而生的自动化工具,专为抓取、整理和本地化 [Kenney.nl](https://kenney.nl/assets) 免费资源库而设计。支持批量提取资源信息、下载素材包和图片,并可生成本地资源索引,方便在离线环境中高效使用。
---
## 📁 项目结构
```plaintext
Kenney-Asset-Scrapper/
├── frontend/ # 已废弃的旧前端版本v1~v3
│ ├── v1/
│ ├── v2/
│ └── v3/
├── scrapper/ # 爬虫与处理核心
│ ├── main.py # 爬取所有资源链接与详情
│ ├── asset_downloader.py # 批量下载 ZIP 素材包
│ ├── image_downloader.py # 批量下载预览图
│ ├── kenney_data_to_local.py # 替换 JSON 为本地路径
```
---
## 🚀 功能亮点
| 模块 | 功能 |
|------|------|
| `main.py` | 爬取 Kenney 网站资源列表与详情,包括标题、分类、版本日志、预览图与下载链接,并保存为结构化 JSON |
| `asset_downloader.py` | 根据 JSON 批量下载 ZIP 资源,自动分类存储(按类型 + 系列) |
| `image_downloader.py` | 批量下载所有预览图,结构化存储至本地 |
| `kenney_data_to_local.py` | 将所有网络路径(资源/图片)替换为对应的本地路径,方便离线访问或嵌入其他系统 |
---
## 🛠 使用说明
1. **抓取资源页面数据**
```bash
python scrapper/main.py
```
⏳ 会生成 `kenney_links.txt` 和 `kenney_data.json`。
2. **下载 ZIP 素材包**
```bash
python scrapper/asset_downloader.py
```
✅ 下载到 `kenney_assets/`,按分类 & 系列整理。
3. **下载图片预览**
```bash
python scrapper/image_downloader.py
```
🎨 所有图片将下载到 `kenney_assets_images/`,与资源信息匹配。
4. **本地路径替换**
```bash
python scrapper/kenney_data_to_local.py
```
📝 生成 `kenney_data_local.json`,将所有 `download` 和 `images` 字段替换为本地路径。
---
## 🗃 示例结构
```plaintext
kenney_assets/
└── 2D/
└── Roguelike RPG/
└── Roguelike RPG V1.4.zip
kenney_assets_images/
└── 2D/
└── Roguelike RPG/
└── Roguelike RPG/
├── preview1.png
├── preview2.jpg
└── ...
```
---
## 🧪 注意事项
- 所有请求均带有浏览器头User-Agent以防被屏蔽
- 下载任务中加入了随机延迟以模拟人类操作,避免触发反爬机制
- 项目未来将继续支持更多格式,如 CSV 导出、数据库同步、本地 Web UI 预览等
---
## 📦 前端说明
原始 `frontend/` 文件夹中的 v1~v3 版本已**弃用**,请转而使用新的 Vue 前端项目 👉 [`kenney-asset-frontend-vue`](https://github.com/kingsmai/kenney-asset-frontend-vue)
---
## 📜 License
MIT License © 2025 — Inspired by the generosity of **Kenney** and his contributions to the open game development community.
---
如需增强或集成至你的工作流,欢迎提 Issue 或 PR
Let's automate creativity! 🎮✨