Loading...
Loading...
新闻站点内容提取。支持 12 个平台:微信公众号、今日头条、网易新闻、搜狐新闻、腾讯新闻、BBC News、CNN News、Twitter/X、Lenny's Newsletter、Naver Blog、Detik News、Quora。当用户需要提取新闻内容、抓取公众号文章、爬取新闻、或获取新闻JSON/Markdown时激活。
npx skill4agent add nanmicoder/newscrawler news-extractor| 平台 | ID | URL 示例 |
|---|---|---|
| 微信公众号 | | |
| 今日头条 | toutiao | |
| 网易新闻 | netease | |
| 搜狐新闻 | sohu | |
| 腾讯新闻 | tencent | |
| 平台 | ID | URL 示例 |
|---|---|---|
| BBC News | bbc | |
| CNN News | cnn | |
| Twitter/X | | |
| Lenny's Newsletter | lenny | |
| Naver Blog | naver | |
| Detik News | detik | |
| Quora | quora | |
cd .claude/skills/news-extractor
uv syncuv runpython| 包名 | 用途 |
|---|---|
| pydantic | 数据模型验证 |
| requests | HTTP 请求 |
| curl_cffi | 浏览器模拟抓取 |
| tenacity | 重试机制 |
| parsel | HTML/XPath 解析 |
| demjson3 | 非标准 JSON 解析 |
# 提取新闻,自动检测平台,输出 JSON + Markdown
uv run .claude/skills/news-extractor/scripts/extract_news.py "URL"
# 指定输出目录
uv run .claude/skills/news-extractor/scripts/extract_news.py "URL" --output ./output
# 仅输出 JSON
uv run .claude/skills/news-extractor/scripts/extract_news.py "URL" --format json
# 仅输出 Markdown
uv run .claude/skills/news-extractor/scripts/extract_news.py "URL" --format markdown
# Twitter 受保护推文 (需要 Cookie)
uv run .claude/skills/news-extractor/scripts/extract_news.py "URL" --cookie "auth_token=xxx; ct0=yyy"
# 列出支持的平台
uv run .claude/skills/news-extractor/scripts/extract_news.py --list-platforms./output{news_id}.json{news_id}.md{
"title": "文章标题",
"news_url": "原始链接",
"news_id": "文章ID",
"meta_info": {
"author_name": "作者/来源",
"author_url": "",
"publish_time": "2024-01-01 12:00"
},
"contents": [
{"type": "text", "content": "段落文本", "desc": ""},
{"type": "image", "content": "https://...", "desc": ""},
{"type": "video", "content": "https://...", "desc": ""}
],
"texts": ["段落1", "段落2"],
"images": ["图片URL1", "图片URL2"],
"videos": []
}# 文章标题
## 文章信息
**作者**: xxx
**发布时间**: 2024-01-01 12:00
**原文链接**: [链接](URL)
---
## 正文内容
段落内容...

---
## 媒体资源
### 图片 (N)
1. URL1
2. URL2uv run .claude/skills/news-extractor/scripts/extract_news.py \
"https://mp.weixin.qq.com/s/ebMzDPu2zMT_mRgYgtL6eQ"uv run .claude/skills/news-extractor/scripts/extract_news.py \
"https://www.bbc.com/news/articles/c797qlx93j0o"# 公开推文 (无需认证)
uv run .claude/skills/news-extractor/scripts/extract_news.py \
"https://x.com/BarackObama/status/896523232098078720"
# 受保护推文 (需要 Cookie)
uv run .claude/skills/news-extractor/scripts/extract_news.py \
"https://x.com/user/status/123456" --cookie "auth_token=xxx; ct0=yyy"| 错误类型 | 说明 | 解决方案 |
|---|---|---|
| URL 不匹配任何支持的平台 | 检查 URL 是否正确 |
| 非支持的站点 | 本 Skill 仅支持列出的 12 个平台 |
| 网络错误或页面结构变化 | 重试或检查 URL 有效性 |
| Twitter Cookie 无效 | 重新获取 Cookie |
news-extractor/
├── SKILL.md # [必需] Skill 定义文件
├── pyproject.toml # 依赖管理
├── references/
│ └── platform-patterns.md # 平台 URL 模式说明
└── scripts/
├── extract_news.py # CLI 入口脚本
├── models.py # 数据模型
├── detector.py # 平台检测
├── formatter.py # Markdown 格式化
└── crawlers/ # 爬虫模块
├── __init__.py
├── base.py # BaseNewsCrawler 基类
├── fetchers.py # HTTP 获取策略
├── wechat.py # 微信公众号
├── toutiao.py # 今日头条
├── netease.py # 网易新闻
├── sohu.py # 搜狐新闻
├── tencent.py # 腾讯新闻
├── bbc.py # BBC News
├── cnn.py # CNN News
├── twitter.py # Twitter/X
├── twitter_client.py # Twitter API 客户端
├── twitter_types.py # Twitter 数据类型
├── lenny.py # Lenny's Newsletter
├── naver.py # Naver Blog
├── detik.py # Detik News
└── quora.py # Quora