hackernews-frontpage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Hacker News front-page scraper

Hacker News首页抓取工具

Scrapes the Hacker News (
news.ycombinator.com
) front page and returns the top 30 stories as JSON. Each story has its rank, title, link URL, point count, and comment count.
抓取Hacker News(
news.ycombinator.com
)首页内容,并以JSON格式返回前30条帖子。每条帖子包含排名、标题、链接URL、点赞数和评论数。

Usage

使用方法

$ $B skill run hackernews-frontpage
{
  "stories": [
    { "rank": 1, "title": "...", "url": "...", "points": 412, "comments": 87 },
    ...
  ],
  "count": 30
}
$ $B skill run hackernews-frontpage
{
  "stories": [
    { "rank": 1, "title": "...", "url": "...", "points": 412, "comments": 87 },
    ...
  ],
  "count": 30
}

How it works

工作原理

  1. Navigates to
    https://news.ycombinator.com
    via the daemon.
  2. Reads the page HTML.
  3. Parses each story row (HN's stable
    tr.athing
    structure) into a typed
    Story
    record.
  4. Emits a single JSON document on stdout.
  1. 通过守护进程导航至
    https://news.ycombinator.com
  2. 读取页面HTML内容。
  3. 将每个帖子行(HN稳定的
    tr.athing
    结构)解析为类型化的
    Story
    记录。
  4. 在标准输出中输出单个JSON文档。

Why this is the reference skill

为何这是参考技能

hackernews-frontpage
is the smallest interesting browser-skill: no auth, stable HTML, deterministic output, file-fixture-friendly. Every Phase 1 component (SDK, scoped tokens, three-tier lookup, spawn lifecycle) is exercised by
$B skill run hackernews-frontpage
and the bundled
script.test.ts
.
When the HN HTML rotates and our selectors break, the test fails against the captured fixture before users notice. That's the point.
hackernews-frontpage
是最小型的实用浏览器技能:无需认证、HTML结构稳定、输出确定、支持文件测试用例。
$B skill run hackernews-frontpage
命令及配套的
script.test.ts
会用到第一阶段的所有组件(SDK、作用域令牌、三级查找、生成生命周期)。
当HN的HTML结构更新导致我们的选择器失效时,测试会在用户发现前就针对捕获的测试用例失败。这正是该工具的意义所在。