hackernews-frontpage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHacker News front-page scraper
Hacker News首页抓取工具
Scrapes the Hacker News () front page and returns the
top 30 stories as JSON. Each story has its rank, title, link URL, point count,
and comment count.
news.ycombinator.com抓取Hacker News()首页内容,并以JSON格式返回前30条帖子。每条帖子包含排名、标题、链接URL、点赞数和评论数。
news.ycombinator.comUsage
使用方法
$ $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
工作原理
- Navigates to via the daemon.
https://news.ycombinator.com - Reads the page HTML.
- Parses each story row (HN's stable structure) into a typed
tr.athingrecord.Story - Emits a single JSON document on stdout.
- 通过守护进程导航至。
https://news.ycombinator.com - 读取页面HTML内容。
- 将每个帖子行(HN稳定的结构)解析为类型化的
tr.athing记录。Story - 在标准输出中输出单个JSON文档。
Why this is the reference skill
为何这是参考技能
hackernews-frontpage$B skill run hackernews-frontpagescript.test.tsWhen the HN HTML rotates and our selectors break, the test fails against the
captured fixture before users notice. That's the point.
hackernews-frontpage$B skill run hackernews-frontpagescript.test.ts当HN的HTML结构更新导致我们的选择器失效时,测试会在用户发现前就针对捕获的测试用例失败。这正是该工具的意义所在。