Files
FacereDataset/docs/sources/oshwhub.md
Zhang Jiahao 5ffa10f256 Phase 1 MVP: crawl 10 high-quality oshwhub projects into LFS
Why:
- Charles 指定:先爬 10 个高质量项目存 Gitea LFS,一个项目一个文件夹,
  保留原文件和 URL。先以小批量验证 schema + LFS 流水线,放量前再拍板
  存储规模。

What:
- crawlers/oshwhub: 列表 API (`/api/project?sort=hot`) + SSR HTML 解析,
  一次性产出 metadata / description / cover / files / _urls
- schemas/project.schema.json: 跨源统一 schema
- docs/sources/oshwhub.md: API 入口 / 字段映射 / 陷阱调研
- pyproject.toml: httpx[http2] 单依赖
- .gitattributes: data/raw/**/files/** 一律走 LFS(规则写窄,避免误伤 schemas/*.json 等)
- .gitignore: 移除 data/raw/* 排除(改走 LFS 入库)

10 个项目覆盖:调试器 / 加热台 / 盖革计数器 / 数控电源 / 焊台 /
智能手表 / USB 测电流 / ZVS 感应加热 / AI 开发板 / 红外热成像。
共 52 附件 ≈ 524 MB 入 LFS,筛选判据 grade=4 & likes>=100 & 多样性。

Known gaps(见 plan.md § Phase 1.4):
- EasyEDA 源 JSON 需登录 (u.lceda.cn),v0.1 跳过
- fs-web-stream.jlc.com 的工程源下载未测
- scripts/validate.py 自动 schema 校验未实现

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 19:34:09 +08:00

93 lines
3.6 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.
# oshwhub.com 数据源调研
**平台**:立创开源硬件平台(嘉立创 EDA / 深圳创电优选科技有限公司)
**URL**https://oshwhub.com
**调研日期**2026-04-23
## 站点架构
- Next.js App Router SPA详情页 `/detail/<uuid>``/<user>/<slug>` 均 SSRHTML 内含完整元数据 + attachments 数组)
- axios baseURL 为 `https://oshwhub.com`(见 `/_next/static/chunks/8661-*.js`
- 首页 / explore 列表数据靠客户端 fetch 渲染(首屏 HTML 里没有卡片 DOM
## robots.txt
```
User-agent: *
Disallow: /posts
Sitemap: https://oshwhub.com/sitemap.xml
```
详情页、explore、API 均允许抓取。
## 可用 API无需鉴权
### 项目列表
`GET https://oshwhub.com/api/project?page=N&pageSize=M&sort=hot`
- `sort``hot`(默认,按热度)/`like`/`new`
- `pageSize`:最大 50 可用,试过 100 返回空
- 返回:`{success, code, result:{page, pageSize, total, totalPage, lists:[...]}}`
- total ≈ 124932026-04 快照)
每条 list item 字段:
- `uuid`, `name`, `introduction`, `path`= `<username>/<slug>`
- `owner``{uuid, username, nickname, avatar, team}`
- `count``{fork, star, like, views, watch}`
- `grade`1-44 是精品徽章)
- `thumb`(封面 URL`image.lceda.cn``//image.lceda.cn` 前缀)
- `created_at`, `updated_at`, `oshwhub_publish_at`
- `tags`, `public`, `publish`, `comments_count`
### 项目详情HTML 解析)
`GET https://oshwhub.com/<path>``/detail/<uuid>`
HTML 内嵌 escaped JSON关键字段
- `\"license\":\"GPL 3.0\"` 等(许可证)
- `\"creator\":{\"uuid\":\"...\"}`
- `\"attachments\":[{ name, src, mime, ext, size, md5, download_count, uuid }, ...]`
- `<title>` 含项目名;`<meta name="description">` 含 introduction
### 文件下载
- **附件** (`attachments[].src`)`https://image.lceda.cn{src}`
- 例:`/attachments/2020/7/mRn5hQZRhmx5r4usGxFmy8BXsCIHw5QoAT5HaLGC.pdf`
- 已验证 HTTP 200无鉴权
- 覆盖 PDF / ZIP / MP4 等
- **工程源文件** (`fs-web-stream.jlc.com/fs-web-stream/file-operation/download/<snowflake-id>`)
- HTML 里出现,但能否直接下载未测试
- 优先级P1v0.1 先不抓
### 未找到 / 留作后续
- EasyEDA 工程源 JSONschematic/PCB 的真正源):推测在 `u.lceda.cn` 下,需登录
- 项目详情 JSON API`/api/project/<uuid>` 返回 `{"code":104001,"success":false}`(试过 GET/POST/路径形式均失败,疑似此端点需 session
## 已知字段与 schema 映射
| 本项目 schema 字段 | oshwhub 来源 |
|-----|-----|
| `source` | 常量 `"oshwhub"` |
| `source_url` | `https://oshwhub.com/<path>` |
| `project_id` | `uuid` |
| `title` | `name` |
| `description` | HTML `<meta description>` + 长描述HTML 正文截取) |
| `author` | `owner.nickname` / `owner.username` |
| `license` | HTML 嵌入 JSON 的 `license` 字段 |
| `created_at` / `updated_at` | 列表 API 同名字段 |
| `crawled_at` | 运行时写入 |
| `tags` | 列表 API `tags` |
| `files[]` | `attachments[]` 映射 |
| `metrics` | `count.{like,star,fork,views}` + `grade` |
## 速率与礼貌
- 列表 API空载实测 < 300ms无限流
- 详情页 HTML~500KB/个,建议 QPS ≤ 0.5
- 附件CDN `image.lceda.cn`,无需限流但建议 1s 间隔
## 陷阱 / 待确认
1. `fs-web-stream.jlc.com` 下载是否需 referer / cookie未测
2. 长描述(含图片、表格)的 HTML 提取保真度,可能需要保留原 HTML
3. `license` 字段取值集合未枚举完(已见:`GPL 3.0` / `CC-BY-SA`...需全量跑后统计)
4. `grade=4` 大概率是精品徽章但文档未说明具体判据