neko-watch
v0.1.5
Published
Utilities for collecting product data from Japanese marketplaces.
Readme
neko-watch
面向 BOOTH 与 Melonbooks 等日系同人市场的商品信息采集工具,提供统一的 TypeScript 接口与 CLI。
安装
npm install neko-watch
# 或者使用 bun add / pnpm add / yarn add快速上手:直接使用 getProduct
import { getProduct } from "neko-watch";
const result = await getProduct("https://booth.pm/ja/items/5679925");
console.log(result.marketplace); // "booth" | "melon"
console.log(result.product.name);- 脚本会自动解析链接域名并调用对应站点的采集器。
- 如果需要传入自定义参数,可通过
getProduct(url, { booth: {...}, melon: {...} })覆盖默认行为。
仍可单独使用 booth 或 melon 辅助函数做站点专用抓取:
import { booth, melon } from "neko-watch";
const boothProduct = await booth("https://booth.pm/ja/items/3276669");
const melonProduct = await melon(
"https://www.melonbooks.co.jp/detail/detail.php?product_id=2344504",
);CLI 用法
构建后可直接通过 Node CLI 获取商品 JSON:
npm run build
node ./build/index.js https://booth.pm/ja/items/3276669CLI 会输出与 getProduct 相同结构的 JSON,便于在管道中继续处理。
示例输出
[
{
"marketplace": "booth",
"product": {
"url": "https://booth.pm/ja/items/3276669",
"name": "Complex 〜宇佐見蓮子の黒歴史ノート〜",
"description": "Water Color Melody.による東方アレンジ4作目「Complex」は、秘封倶楽部・宇佐見蓮子の過去をえぐり出すコンセプトアルバム。\nメリーと出会う以前、不完全な少女は何を考え何を求めていたのか。\n痛いだけじゃない、その「黒歴史」にそっと触れてみたくはありませんか?\n\n▼特設\nhttps://wcm0004.tumblr.com/\n\n\nBOOTH限定のご購入特典で「洒落ならんステッカー」(葉書サイズ・5種)を【1注文につき1つ】プレゼントいたします。\n\n・Complexジャケット(縦長長方形)\n・WCM.ロゴ(横長長方形)\n・WCM.ロゴ(円形/小)\n・ME.HERジャケット(円形/大)\n・古川(円形/中)\n\n取り返しのつかない場所に貼ってお楽しみください。\n\n\n▼デジタル版はこちら\nhttps://wcm.booth.pm/items/3332131\n※デジタル版には歌詞カードなどの印刷物データは付属しません。",
"soldOut": true,
"price": {
"amount": 1000,
"currency": "JPY",
"raw": "1000"
},
"imageUrls": [
"https://booth.pximg.net/c/620x620/e94748fc-0e58-4d48-995c-52141d12f694/i/3276669/c411fb5d-816a-4c47-a8a7-5d378c46dbe8_base_resized.jpg",
"https://booth.pximg.net/e94748fc-0e58-4d48-995c-52141d12f694/i/3276669/c411fb5d-816a-4c47-a8a7-5d378c46dbe8_base_resized.jpg",
"https://booth.pximg.net/e94748fc-0e58-4d48-995c-52141d12f694/i/3276669/c411fb5d-816a-4c47-a8a7-5d378c46dbe8.jpg",
"https://booth.pximg.net/e94748fc-0e58-4d48-995c-52141d12f694/i/3276669/44e31949-dd09-4e13-a6a9-5449996fb72f.jpg",
"https://booth.pximg.net/e94748fc-0e58-4d48-995c-52141d12f694/i/3276669/44e31949-dd09-4e13-a6a9-5449996fb72f_base_resized.jpg"
]
}
},
{
"marketplace": "melon",
"product": {
"url": "https://www.melonbooks.co.jp/detail/detail.php?product_id=2344504",
"name": "Frag2",
"author": "さと",
"circle": "原住民族",
"price": {
"amount": 660,
"currency": "JPY",
"raw": "660"
},
"stockMaxQuantity": 7,
"status": 2,
"statusText": "好評受付中",
"category": "オリジナル",
"genres": [
"オリジナル",
"百合"
],
"imageUrls": [
"//melonbooks.akamaized.net/user_data/packages/resize_image.php?image=212001436402.jpg",
"//melonbooks.akamaized.net/user_data/packages/resize_image.php?image=212001436402a.jpg&sp=1",
"//melonbooks.akamaized.net/user_data/packages/resize_image.php?image=212001436402b.jpg&sp=1",
"//melonbooks.akamaized.net/user_data/packages/resize_image.php?image=212001436402c.jpg&sp=1",
"//melonbooks.akamaized.net/user_data/packages/resize_image.php?image=212001436402d.jpg&sp=1"
]
}
}
]TypeScript 接口速查
| 类型 | 说明 |
| ---- | ---- |
| Marketplace | 当前支持的站点标识,"booth" 或 "melon"。 |
| AggregatedProduct | getProduct 与 CLI 返回的封装结果,包含 marketplace 与 product。 |
| FetchBoothProductOptions | Booth 抓取器可选配置,如自定义 fetch、静态 HTML 或额外请求头。 |
| BoothProduct | Booth 商品解析后的结构化数据。 |
| FetchMelonProductOptions | Melonbooks 抓取器可选配置。 |
| MelonProduct | Melonbooks 商品解析后的结构化数据。 |
| FetchLike | 兼容的 fetch 函数签名,可注入自定义实现。 |
| GetProductOptions | getProduct 的站点参数集合。 |
完整定义可在项目根目录的 type.ts 中查看。
构建与测试
npm run build
npm test产物位于 build/,包括 ES Module、类型声明与源码映射,方便集成到 Node.js 与构建链路中。
