360 Secure SkillHub
360 安全技能中心

Apify HN Scraper

该工具通过Apify Actor的REST API抓取Hacker News的故事、评论与讨论。核心功能支持按关键词搜索、指定最大结果数、选择排序方式,可按需包含评论。典型场景为用户搜索HN帖子、监控技术讨论、提取HN数据时使用。需提前设置APIFY_TOKEN环境变量,系统需具备curl和jq工具。输入为用户指定的抓取参数,输出可呈现结果摘要,也支持JSON/CSV导出。

marcindudekdev
marcindudekdev
热度 85.50
最近更新 2026-05-17 13:37:43
分类:自动化依赖:代码执行 / 第三方 API应用场景:数据处理 / 研究

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add apify-hn-scraper
Metadata
name
apify-hn-scraper
description
Scrape Hacker News stories, comments, and discussions. Use when user asks to search HN, find Hacker News posts, monitor tech discussions, or extract HN data. Requires APIFY_TOKEN environment variable.
metadata
{"openclaw":{"emoji":"🟧","requires":{"env":["APIFY_TOKEN"],"bins":["curl","jq"]},"primaryEnv":"APIFY_TOKEN"}}

Hacker News Scraper

Scrape Hacker News using an Apify Actor via the REST API.

Actor ID

0UDODOnpTkxY3Oc90

Prerequisites

  • APIFY_TOKEN environment variable must be set
  • curl and jq must be available

Workflow

Step 1: Confirm parameters with user

Ask what they want to scrape. Supported input fields:

  • searchTerms (array of strings) - keywords to search
  • maxResults (integer) - max stories to return
  • sortBy (string) - "points", "date", or "relevance"
  • includeComments (boolean) - include comment threads

Step 2: Run the Actor

RESULT=$(curl -s -X POST "https://api.apify.com/v2/acts/0UDODOnpTkxY3Oc90/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"searchTerms": ["TERM"], "maxResults": 30}')
echo "$RESULT" | jq '.'

Step 3: Poll and fetch (if async)

RUN_ID=$(curl -s -X POST "https://api.apify.com/v2/acts/0UDODOnpTkxY3Oc90/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"searchTerms": ["TERM"], "maxResults": 100}' | jq -r '.data.id')
curl -s "https://api.apify.com/v2/actor-runs/$RUN_ID?token=$APIFY_TOKEN" | jq -r '.data.status'
curl -s "https://api.apify.com/v2/actor-runs/$RUN_ID/dataset/items?token=$APIFY_TOKEN" | jq '.'

Step 4: Present results

Summarize: top stories by points, comment counts, domains, trends. Offer JSON/CSV export.

Error Handling

  • If APIFY_TOKEN not set: export APIFY_TOKEN=your_token
  • If run FAILS: check log endpoint