新闻爬虫工程

SKILL研究检索
研究检索 未标注权限 许可证不明确
安装这个技能

Design, implement, review, and harden news/information crawlers as production data pipelines. Use when the user asks to build, analyze, debug, or refactor news website crawlers, market news crawlers, public opinion/news scraping, article list/detail extraction, pagination, incremental backfill, anti-bot analysis, or crawler database schemas.

一句话选型结论

按资料字段整理

新闻爬虫工程是研究检索类的 Agent Skill,安装方式未标注,权限级别未标注,许可证不明确,有可直接复制的安装命令。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类研究检索 安装方式未标注 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 未标注
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

未标注
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
skillhub install user_756344a1/news-crawler-engineering
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    执行上面的命令安装;也可以把仓库里的 SKILL.md 手动放进客户端的 skills 目录。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

研究检索
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方user_756344a1仓库 未标注 · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式未标注安装包 community
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 1791736306
正文体量11.0 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
查资料并整理出处

让模型按主题查资料,并把引用来源整理成清单。

网页与文献要点提炼

把长文、论文、网页压成能直接看的要点。

竞品与行业汇总

按关键词汇总竞品动态与行业信息。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有可直接复制的安装命令,不用自己翻文档找入口。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在研究检索场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
新闻爬虫工程当前 未标注权限 未标注 未标注 未标注 有
寻找技能 浏览器控制 GitHub 仓库 3120.0 万 Codex、Claude、Cursor 有
自我改进 Agent 接触敏感数据 ClawHub 市场 1646.4 万 OpenClaw 有
灵魂追踪 联网访问 GitHub 仓库 758.9 万 Codex、Claude、Cursor 有
自我完善 联网访问 ClawHub 市场 682.9 万 OpenClaw 有
微软代工厂 调用外部服务 GitHub 仓库 661.4 万 Codex、Claude、Cursor 有

SKILL.md 全文

11.0 KB
模型实际读到的说明书原文,来自技能仓库

News Crawler Engineering

Use this skill whenever working on news/information crawlers. Treat each site as one source in a long-running news collection system, not as a one-off page parser.

Workflow

  1. Recon first:
    - Find the real list API, pagination params, column/channel IDs, detail URL rule.
    - Check whether list API returns title, timestamp, real source, images, summary, and full content.
    - Inspect page source and JS for ajax, fetch, page, pageNum, columnId, channel.
    - Use browser Network and user-js-reverse MCP when JS/signature/cookie logic is involved.
    - Do not implement before confirming pagination and the real data entry point.

  2. Pick collection mode:
    - API includes full content: use API as primary source; fetch detail only to enrich missing fields.
    - API is list-only: use API for list/pagination, detail page for content.
    - Static HTML only: parse paginated HTML + details.
    - Strong CSR/anti-bot: reverse API/signature first, then replay.

  3. Design data model before coding:
    - Use get_market_news_info as the lightweight main table.
    - Use get_market_news_content for content, content_html, images, and raw_data.
    - Both tables use the business unique key:
    sql UNIQUE KEY `uk_source_unique_id` (`source`,`source_unique_id`)
    - news_id is only a relation/index, not the content table unique key.
    - Keep large fields out of the main table.

Field Rules

  • media_name: collection site name.
  • original_source: true source displayed by the article, empty string if unavailable.
  • summary: article-specific summary only; never store fixed site description, column intro, or template text.
  • author: do not use editor as a fake author.
  • stock_list: 文章关联的个股代码列表,格式为纯字符串数组 ["AAPL", "INTC"]。页面或接口有就提取,没有就存空数组 []。不要存对象数组,不要附带URL等额外信息。
  • crawl_error: short error only; do not store full HTML/response bodies.
  • Site-specific lightweight fields go to extra_data; large/raw fields go to the content table.
  • Content success rule:
  • Text content exists: success.
  • No text but images is non-empty: success; keep content empty and store content_html if available.
  • No text and no images: crawl_status = 4 / body empty.

Content Extraction

Prefer structured API data over HTML parsing for content extraction.

Data source priority:

  1. API blocks/paragraphs/segments (most reliable, exact paragraph boundaries).
  2. HTML detail page with known content container selector (fallback).
  3. Full-page get_text() split by newline (last resort).

Paragraph rules:

  • Separate paragraphs with \n\n (double newline), not single \n.
  • When using API blocks, each text block = one paragraph; concatenate inline tokens within a block.
  • If the API blocks omit the article intro/teaser (common pattern), prepend description as the first paragraph.
  • When falling back to HTML: prefer <p> tags; also consider <h2>–<h4>, <blockquote>, <li> as paragraph-level elements. Skip non-content areas (disclaimers, author bios, related articles) by scoping to the correct content container first.
  • If no <p> tags exist, fall back to splitting get_text("\n") and filtering empty lines.

Image position in content:

  • When the source provides block-structured data with interleaved text and image blocks, insert a placeholder [图片:caption] in content at the image's position to preserve the spatial relationship between text and images.
  • images field stores the full URL list (ordered by appearance).
  • content_html preserves the original HTML structure for re-rendering if needed.

Why this matters:

  • Modern sites (React/Next.js SSR) often return incomplete HTML (images rendered by JS, content behind hydration). The API is the source of truth.
  • HTTP headers cannot contain non-ASCII characters. When the detail page URL or Referer contains Chinese/Unicode, URL-encode it (urllib.parse.quote).

Incremental and Backfill

News crawlers must support first-time backfill, daily incremental collection, failed retry, batched dedupe, and resumability.

Standard strategy:

  1. Query MAX(publish_time) per source + column_name.
  2. If no history exists, threshold is now - backfill_days (default 90 days).
  3. If history exists, threshold is max_publish_time - overlap_hours (default 6 hours).
  4. Iterate by column and page.
  5. For each page, batch-dedupe candidates with IN (...).
  6. Fetch/parse details for that page.
  7. Immediately upsert that page into DB.
  8. Stop paging when the whole page is older than threshold.

Never collect all columns/all historical pages into memory and only insert at the end.

Storage and Status

  • Write main and content tables in the same transaction.
  • Use INSERT ... ON DUPLICATE KEY UPDATE.
  • Failed records should also be stored for retry and diagnosis.

crawl_status:

  • 1: success
  • 2: detail request failed
  • 3: page structure abnormal
  • 4: body empty
  • 5: parse exception

Code Comments

File header: every crawler script must include a module docstring with @Desc followed by a 来源url: line pointing to the target page URL. This makes it easy to locate the crawl target when debugging.

"""
@Author: you name
@File  : 香港01财经快讯.py  python3
@Desc  : 香港01(www.hk01.com 繁体站)財經快訊抓取
来源url:https://www.hk01.com/channel/396/%E8%B2%A1%E7%B6%93%E5%BF%AB%E8%A8%8A
"""

Add concise comments to non-obvious logic. Do not narrate what code does line-by-line. Focus on:

  • Method docstrings: one-line summary of purpose and return value. Example: """获取增量抓取的时间阈值:表里有数据则取最新时间-overlap_hours,无数据则回溯backfill_days天"""
  • Branch intent: explain why a branch exists when the condition alone isn't self-explanatory. Example: if not self.db_pool: # 本地调试无DB时直接走全量回溯
  • Business logic: threshold calculation, stop conditions, dedup strategy. Example: should_stop = (not page_has_newer) # 本页全部早于阈值则停止翻页
  • Non-obvious fallbacks: when code has multiple data source priorities or fallback paths, annotate the intent. Example: if not content_text: # blocks为空时兜底用HTML提取

Do NOT comment:
- Imports, variable assignments, obvious operations.
- What a function call does (the function name should be self-documenting).

Monitoring & Alerting

每个爬虫必须内置监控报警,不能依赖外部监控平台单独配置。

三层报警(必须全部实现):

  1. 程序崩溃:未捕获异常 → 飞书/通知 "程序报错"。
  2. 零数据入库:total_success == 0 → 飞书/通知 "0条数据入库,请检查网站或API是否异常"。
  3. 详情失败率过高:total_fail / (total_success + total_fail) > 0.5 → 飞书/通知 "失败率过高,可能触发反爬"。
# main() 示例结构
def main():
    crawler = XxxCrawler(max_workers=3)
    total_success, total_fail = crawler.run()

    if total_success == 0:
        notify("本次执行0条数据入库,请检查网站或API是否异常")
    elif total_fail > 0 and total_fail / (total_success + total_fail) > 0.5:
        notify("详情抓取失败率过高,可能触发反爬")

if __name__ == "__main__":
    try:
        main()
    except Exception as err:
        notify(f"程序报错: {err}")
        raise

连续空页中断:

  • 列表API连续 N 页(建议3页)返回空结果时,主动中断并打印警告。
  • 防止API挂了但程序还在傻翻页浪费时间。

Pagination Stop Logic

翻页停止条件需要区分两种情况,不能混为一谈:

情况 should_stop consecutive_empty 动作
本页所有文章早于阈值 True 不累加 正常结束(翻到底了)
API请求失败/返回空 False +1 交给连续空页计数处理

关键原则:

  • API 失败时返回 ([], False) 而非 ([], True)。
  • should_stop=True 仅当确认页面有数据但全部早于阈值时才设置。
  • consecutive_empty 的判断必须在 seen 去重之前,用 raw_tasks(原始列表结果)判断,而非去重后的 tasks。
for page in range(max_pages):
    raw_tasks, should_stop = self.parse_list_page(end_index, threshold)

    if not raw_tasks:
        consecutive_empty += 1
        if consecutive_empty >= 3:
            print(f"警告:连续{consecutive_empty}页为空,可能API异常")
            break
    else:
        consecutive_empty = 0

    tasks = [t for t in raw_tasks if t["id"] not in seen]
    seen.update(t["id"] for t in tasks)
    tasks = self.filter_not_exists(tasks)
    # ... process tasks ...

    if should_stop:
        break

Proxy & Network

  • 不是所有网站都需要代理。海外网站(如 CNBC、Reuters)从香港/海外服务器直连即可,国内代理反而会被拦截(如 449 Foreign Host Forbidden)。
  • 当环境变量配置了默认代理时,对不需要代理的站点必须显式传 proxies={} 绕过。
  • 在实现前先测试目标站点是否需要代理、是否有 TLS 指纹检测,不要假设。
# 需要绕过默认代理的请求
new_request("GET", url, "json", proxies={}, headers=headers)

Memory Management

  • task 列表中只存入库和详情解析所需的字段,不要把 API 原始完整 JSON 塞进 task dict。
  • raw_data 字段入库时从 item 构建即可,不需要提前存储完整 API 响应。
  • 大批量场景下(单次数百条 task),避免在内存中积累所有页的 tasks 后才开始处理,应逐页处理+入库。

Verification Checklist

Do not stop at syntax/lint checks. Verify:

  • Table structures and unique keys match the model.
  • One sample writes to both main and content tables.
  • JSON fields are valid.
  • Chinese/Unicode encoding is correct.
  • summary is a real article summary.
  • original_source is the true article source.
  • Re-running skips successful rows.
  • Failed rows can be retried.
  • Run the script end-to-end (list → detail → parse) before delivering. Syntax checks alone are insufficient.
  • Alerting works: 确认零数据/高失败率/崩溃三种场景都能触发通知。
  • Proxy correctness: 确认目标站点请求不被代理拦截(海外站传 proxies={})。

Recommended Class Responsibilities

Prefer a class-based crawler with these responsibilities:

  • column configuration
  • list/API request
  • list field mapping
  • per-column threshold calculation
  • batched dedupe
  • detail parsing
  • failed item construction
  • transactional main/content upsert
  • page-by-page column runner

常见问题

5 问
答案由本站依据条目字段整理
新闻爬虫工程怎么安装?

在支持 Skills 的客户端里执行:skillhub install user_756344a1/news-crawler-engineering。安装方式为未标注。装完刷新技能列表或重开客户端。

新闻爬虫工程支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

新闻爬虫工程权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

新闻爬虫工程收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

新闻爬虫工程用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。