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.37

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               # 版本

按城市搜索酒店

CLI 默认行为:省略 --platform 时会并行爬携程 + 道旅 + 汇智 + 客路 + 飞猪(各开独立后台 tab),结果汇总到 results。 单平台 stdout 为扁平结构(无 results 包裹),便于智能体按平台合并比价。某条失败只影响该平台,可单独重跑该条。 人工调试或本地一次性看汇总时,仍可用全平台并行:

# 五平台并行(数据量大,智能体不推荐)
hbc get hotel --city 北京
hbc get hotel --city 北京 --searchWord "7天"

# 单平台示例
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 | 智能体建议必填 | ctripdidahuizhiklookfliggy;省略=五平台并行(不推荐 Bot 使用) | | --searchWord | 否 | 酒店关键词(汇智/客路 = 城市 + 关键词) | | --checkin | 否 | YYYY-MM-DD,默认明天 | | --checkout | 否 | YYYY-MM-DD,默认后天

给智能体 / Bot 的推荐不要省略 --platform 一次性拉全平台。原因:

  • 多平台 × 各 top5 酒店 × 多房型,单次 stdout 体积大,上下文占用高
  • 多 tab 同时爬取更容易超时、部分平台 ok: false,反而要补跑

按平台拆成多条命令(相同 --city / --searchWord / 入离日期),逐条执行、逐条合并 JSON

多平台并行返回 { ok, search, results: [...] }。stderr 含每条酒店完成/失败原因;超时按无进度空闲续期(默认 80s,上限约 160s)。示例:

[hbc] 开始并行爬取: 携程、道旅、汇智、客路
[hbc] 道旅 北京如家的酒店:url:https://portal.dida.com/...
[hbc] 第一条:如家酒店
[hbc] 第一条完成:如家酒店
[hbc] 第二条失败:xxx(10s内未拿到数据)
[hbc] 道旅 部分完成 2/5 条
[hbc] 道旅 未完成:80s 内无新进度/响应;末条进度:第三条:xxx

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

携程机票(按城市搜索)

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。按城市搜索时会带上拼好的 url 和抓取 result

多平台酒店搜索示例:

{
  "ok": true,
  "kind": "hotel",
  "search": {
    "city": "北京",
    "searchWord": "如家",
    "checkin": "2026-06-05",
    "checkout": "2026-06-06",
    "platforms": ["ctrip", "dida", "huizhi", "klook", "fliggy"]
  },
  "results": [
    {
      "platform": "ctrip",
      "ok": true,
      "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内未拿到数据" }
      ]
    }
  ]
}

单平台 --platform klook 时扁平输出(无 results 包裹):

{
  "ok": true,
  "kind": "hotel",
  "platform": "klook",
  "search": { "city": "北京", "searchWord": "如家", "checkin": "...", "checkout": "..." },
  "hotelCount": 5,
  "successCount": 2,
  "hotels": [ ... ]
}

传单个酒店 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 }] }

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

HBC_RESPONSE_TIMEOUT_MS=60000 hbc get hotel --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. 解析扁平 JSON(单平台无 results 外层),按 platform 字段或命令参数合并。
  4. 某平台 ok: falsesuccessCount === 0 时,只重跑该平台那条,不必重跑其它已成功的平台。
  5. 道旅 / 汇智 / 客路 / 飞猪须浏览器内对应站点已登录,否则该平台会空结果。

不要对智能体使用省略 --platform 的全平台并行:数据量过大、并发 tab 多、失败率高,补跑成本更高。

机票

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

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 会在后台开页抓取,无需手动打开目标页。

支持平台:

  • 酒店搜索(hbc get hotel --city …):CLI 默认五平台并行;智能体应 --platform 分条执行
  • 机票:flights.ctrip.com 列表页

其他说明

  • 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