npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bitsteven/hbccli

v0.1.38

Published

Local WebSocket hub + CLI to control the yundijie-trip Chrome extension.

Readme

hbccli

跑在本机的命令行工具 + WebSocket 服务。你在终端(或 Bot/智能体通过 shell)执行 hbc get …,CLI 把任务发给 Chrome 里的「小云 AI」扩展;扩展在浏览器里后台打开携程等页面、解析 DOM,再把结果以 JSON 打印到 stdout。

依赖

| 依赖 | 说明 | | ---------------- | ----------------------------------- | | Node.js 18+ | 运行 hbc 命令 | | 「小云 AI」Chrome 扩展 | 实际开页、抓取;须与本 CLI 版本配套 | | hbc start | 启动本地 Hub(默认 ws://localhost:17881) | | 扩展已连接 | 工具栏图标角标为绿色 | | 携程已登录 | 未登录时酒店/机票列表常抓不到数据 |

能做什么

  • 按城市搜酒店,或按出发/到达城市搜携程机票
  • 直接传酒店/机票/道旅等 URL 批量抓取
  • 返回结构化 JSON(房型价、航班列表等),供脚本或 LLM 继续处理
  • 使用前请先 hbc start,并确认扩展角标为绿色。

安装

npm i -g @bitsteven/hbccli@latest
npm view @bitsteven/hbccli    # 查看 npm 最新版本

常用命令

hbc start          # 启动 Hub(后台 daemon,推荐)
hbc stop

hbc open "携程|飞猪"              # 按关键词打开网页
hbc open "https://..."           # 打开指定链接

hbc get "<url>" ["<url>" …]      # 传链接,自动识别 hotel / flight / ticket
hbc get hotel "<url>" …          # 强制按酒店规则
hbc get flight "<url>" …         # 强制按机票规则
hbc get ticket "<url>" …         # 强制按门票规则

hbc -h | --help                  # 帮助
hbc -v | --version               # 版本

按城市搜索酒店

每条命令带 --platform 查单平台,stdout 为扁平 JSON。多平台比价见下文「给 AI / Bot 的用法」。

# 单平台示例
hbc get hotel --platform ctrip --city 北京 --searchWord 如家

# 仅道旅(须已登录 portal.dida.com)
hbc get hotel --platform dida --city 北京 --searchWord 如家

# 仅汇智(须已登录 agency.huitravel.com)
hbc get hotel --platform huizhi --city 北京 --searchWord 如家

# 仅客路(须已登录 klook.klktech.cn)
hbc get hotel --platform klook --city 北京 --searchWord 如家

# 仅飞猪(须已登录 hotel.fliggy.com)
hbc get hotel --platform fliggy --city 北京 --searchWord 如家

| 参数 | 必填 | 说明 | | -------------- | --- | ----------------------------------------- | | --city | 是 | 城市名(携程可用 cityId) | | --platform | 是 | ctrip、dida、huizhi、klook、fliggy | | --searchWord | 否 | 酒店关键词(汇智/客路 = 城市 + 关键词) | | --checkin | 否 | YYYY-MM-DD,默认明天 | | --checkout | 否 | YYYY-MM-DD,默认后天 |

stderr 含抓取进度;超时按无进度空闲续期(默认 80s,上限约 160s)。示例:

[hbc] 道旅 北京如家的酒店:url:https://portal.dida.com/...
[hbc] 第一条:如家酒店
[hbc] 第一条完成:如家酒店
[hbc] 第二条失败:xxx(10s内未拿到数据)
[hbc] 道旅 部分完成 2/5 条

超时/中断时会带平台名与末条进度。

携程机票(按城市搜索)

hbc get flight --from 北京 --to 成都
hbc get flight --from 北京 --to 成都 --depdate 2026-06-05
hbc get flight --way roundtrip --from 上海 --to 曼谷 \
  --depdate 2026-06-05 --retdate 2026-06-12

| 参数 | 必填 | 说明 | | ----------- | --- | ----------------------------- | | --from | 是 | 出发地,如 北京、北京市机场 | | --to | 是 | 目的地 | | --way | 否 | 默认单程 oneway;往返传 roundtrip | | --depdate | 否 | 出发日,默认明天 | | --retdate | 否 | 往返返程日,默认 depdate + 3 天 |

默认 URL 参数:cabin=y_s&adult=1&child=0&infant=0。

城市名对照见包内 config/city_code.json,例如:北京市 → BJS,曼谷 → BKK。


传链接抓取

已有完整 URL 时,直接 hbc get 即可(可一次传多个、混平台):

hbc get \
  "https://flights.ctrip.com/online/list/oneway-bjs-ctu?..." \
  "https://www.ctrip.com/hotels/..." \
  "https://portal.dida.com/..."

链接如何识别品类,见 config/hbcGetRoutes.json(按顺序匹配,先命中先生效):

| 类型 | 匹配要点 | | ------ | --------------------------- | | flight | flights.ctrip.com 列表页,非首页 | | hotel | 携程/Trip 酒店、道旅、汇智、客路 | | ticket | Klook /activity/(待完善) |

机票链接须为搜索结果列表页(如 /online/list/oneway-...),不能是 flights 首页。

酒店链接可以是列表或详情;列表页会依次抓前 5 条详情;详情链只抓一家。


返回结果

命令成功时在终端打印 JSON。单平台 --platform 时为扁平结构:

{
  "ok": true,
  "kind": "hotel",
  "platform": "ctrip",
  "search": { "city": "北京", "searchWord": "如家", "checkin": "2026-06-05", "checkout": "2026-06-06" },
  "hotelCount": 5,
  "successCount": 3,
  "hotels": [
    {
      "ok": true,
      "hotelName": "如家酒店(北京xxx店)",
      "rating": 4.2,
      "lowPrice": 299,
      "address": "朝阳区…",
      "rooms": [
        { "name": "大床房", "price": 299, "bedType": "大床", "breakfast": false, "cancelRule": "不可取消" }
      ]
    },
    { "ok": false, "hotelName": "…", "error": "10s内未拿到数据" }
  ]
}

传单个酒店 URL 时同样扁平;多个 URL 时为 { ok, results: [...] }。

机票示例:

{
  "ok": true,
  "kind": "flight",
  "skillId": "script-ctrip-get-flight",
  "search": {
    "way": "oneway",
    "from": { "input": "北京", "cityName": "北京", "cityCode": "BJS" },
    "to": { "input": "成都", "cityName": "成都", "cityCode": "CTU" },
    "depdate": "2026-06-05"
  },
  "url": "https://flights.ctrip.com/online/list/oneway-bjs-ctu?...",
  "result": {
    "ok": true,
    "url": "https://flights.ctrip.com/online/list/oneway-bjs-ctu?...",
    "kind": "flight",
    "skillId": "script-ctrip-get-flight",
    "result": {
      "flightCount": 10,
      "departCity": "北京",
      "arriveCity": "成都",
      "items": [ ... ]
    }
  }
}

传多个 URL 时:{ ok, count, results: [{ ok, url, kind, result | error }] }

抓取较慢时可加大超时(默认 80 秒):

HBC_RESPONSE_TIMEOUT_MS=120000 hbc get hotel --platform ctrip --city 北京 --searchWord "7天酒店"
HBC_RESPONSE_TIMEOUT_MS=60000 hbc get flight --from 北京 --to 成都

给 AI / Bot 的用法

把 hbc get hotel … / hbc get flight … 当作只读查价工具——在 shell 里调用、读取 stdout 的 JSON,stderr 为进度日志可忽略;不要自己拼 OTA URL(搜索模式用 CLI 参数即可)。

酒店:多平台并发查询 + 汇总

  1. 对同一搜索条件,同时并发发起多条命令(携程 / 道旅 / 汇智 / 客路 / 飞猪各一条,均带 --platform),不要按顺序串行执行——串行太慢。
  2. 每条命令参数保持一致:--city、--searchWord、--checkin、--checkout(命令示例见上文「按城市搜索酒店」)。
  3. 等各条 stdout 返回后,按 platform 汇总比价结果。
  4. 某平台失败时只重跑该平台,不影响其它已成功的结果。

并发示例(shell 后台同时跑):

hbc get hotel --platform ctrip  --city 北京 --searchWord 如家 --checkin 2026-06-11 --checkout 2026-06-12 &
hbc get hotel --platform dida    --city 北京 --searchWord 如家 --checkin 2026-06-11 --checkout 2026-06-12 &
hbc get hotel --platform huizhi  --city 北京 --searchWord 如家 --checkin 2026-06-11 --checkout 2026-06-12 &
hbc get hotel --platform klook   --city 北京 --searchWord 如家 --checkin 2026-06-11 --checkout 2026-06-12 &
hbc get hotel --platform fliggy  --city 北京 --searchWord 如家 --checkin 2026-06-11 --checkout 2026-06-12 &
wait

(若环境支持 parallel tool call / 多进程,等价于上述并发,无需 & + wait。)

某平台数据断层:提示登录或无数据

汇总时若某平台出现以下情况,必须明确告知用户(响应 JSON 中含 needsLogin、loginHint、userHint 字段时可优先引用):

  • ok: false,或 successCount === 0,或 hotels 为空
  • error 含「未登录」「没数据」「超时」「未找到列表」等

| --platform | 平台 | 登录站点 | 提示要点 | | ------------ | --- | -------- | -------- | | ctrip | 携程 | hotels.ctrip.com | 未登录或无数据 → 提示登录携程;仍无结果则可能该平台无匹配酒店 | | dida | 道旅 | portal.dida.com | 同上,道旅门户 | | huizhi | 汇智 | agency.huitravel.com | 同上,汇智 agency | | klook | 客路 | klook.klktech.cn | 同上,客路 | | fliggy | 飞猪 | hotel.fliggy.com | 同上,飞猪酒店 |

单平台失败时 stdout 除 error 外还会附带:

{
  "ok": false,
  "kind": "hotel",
  "platform": "dida",
  "error": "未登录 portal.dida.com(停留在登录页)",
  "needsLogin": true,
  "loginHint": {
    "platform": "dida",
    "label": "道旅",
    "site": "portal.dida.com",
    "openCommand": "hbc open \"道旅\""
  },
  "userHint": "请在 Chrome 登录 portal.dida.com(道旅,hbc open \"道旅\")后重试:hbc get hotel --platform dida …"
}

智能体应把 userHint 转述给用户;needsLogin: false 时表示更可能为该平台暂无匹配酒店。

机票

仍用单条命令即可(仅携程):

hbc get flight --from 北京 --to 成都 --depdate 2026-06-05

安装 Chrome 插件

  1. 获取扩展包(开发版:在 monorepo 根目录 npm run build,加载 dist/)
  2. 打开 chrome://extensions,开启「开发者模式」
  3. 「加载已解压的扩展程序」→ 选择 dist/ 目录
  4. hbc start 后,插件图标角标:绿色已连接 / 红色未连接

使用前建议 登录携程(未登录时列表页常抓不到数据)。
hbc get 会在后台开页抓取,无需手动打开目标页。

支持平台(酒店 --platform):ctrip · dida · huizhi · klook · fliggy;机票:flights.ctrip.com(hbc get flight)


其他说明

  • Hub 默认端口 17881(环境变量 PORT 可改);插件连 ws://localhost:17881
  • Hub 未启动时,hbc get 会自动拉起 daemon
  • Bot 直连 WebSocket 示例(须传完整 URL):
{"cmd":"get","type":"flight","text":"https://flights.ctrip.com/online/list/..."}
{"cmd":"get","text":"https://..."}

接入 Bot 示例:

示例1 示例2