Extract article content from major Chinese news platforms and output in JSON and Markdown formats.
Standalone and portable: This Skill contains all required code with no external dependencies and can be directly copied for use in other projects.
Supported Platforms
| Platform | ID | URL Example |
|---|---|---|
| WeChat Official Accounts | https://mp.weixin.qq.com/s/xxxxx |
|
| Toutiao | toutiao | https://www.toutiao.com/article/123456/ |
| NetEase News | netease | https://www.163.com/news/article/ABC123.html |
| Sohu News | sohu | https://www.sohu.com/a/123456_789 |
| Tencent News | tencent | https://news.qq.com/rain/a/20251016A07W8J00 |
Usage
Basic Usage
# 提取新闻,自动检测平台,输出 JSON + Markdown
uv run .claude/skills/china-news-crawler/scripts/extract_news.py "URL"
# 指定输出目录
uv run .claude/skills/china-news-crawler/scripts/extract_news.py "URL" --output ./output
# 仅输出 JSON
uv run .claude/skills/china-news-crawler/scripts/extract_news.py "URL" --format json
# 仅输出 Markdown
uv run .claude/skills/china-news-crawler/scripts/extract_news.py "URL" --format markdown
# 列出支持的平台
uv run .claude/skills/china-news-crawler/scripts/extract_news.py --list-platforms
Output Files
The script outputs two formats by default to the specified directory (default ./output):
{news_id}.json- Structured JSON data{news_id}.md- Markdown-formatted article
Workflow
- Receive URL - User provides a news link
- Platform Detection - Automatically identify the platform type
- Content Extraction - Call the corresponding scraper to fetch and parse the content
- Format Conversion - Generate JSON and Markdown
- Output Files - Save to the specified directory
Output Format
JSON Structure
{
"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": []
}
Markdown Structure
# 文章标题
## 文章信息
**作者**: xxx
**发布时间**: 2024-01-01 12:00
**原文链接**: [链接](URL)
---
## 正文内容
段落内容...

---
## 媒体资源
### 图片 (N)
1. URL1
2. URL2
Usage Examples
Extract a WeChat Official Account article
uv run .claude/skills/china-news-crawler/scripts/extract_news.py \
"https://mp.weixin.qq.com/s/ebMzDPu2zMT_mRgYgtL6eQ"
Output:
[INFO] Platform detected: wechat (微信公众号)
[INFO] Extracting content...
[INFO] Title: 文章标题
[INFO] Author: 公众号名称
[INFO] Text paragraphs: 15
[INFO] Images: 3
[SUCCESS] Saved: ./output/ebMzDPu2zMT_mRgYgtL6eQ.json
[SUCCESS] Saved: ./output/ebMzDPu2zMT_mRgYgtL6eQ.md
Extract a Toutiao article
uv run .claude/skills/china-news-crawler/scripts/extract_news.py \
"https://www.toutiao.com/article/7434425099895210546/"
Dependency Requirements
This Skill requires the following Python packages (usually already installed in the main project):
- parsel
- pydantic
- requests
- curl-cffi
- tenacity
- demjson3
Error Handling
| Error Type | Description | Solution |
|---|---|---|
无法识别该平台 |
URL does not match any supported platform | Check whether the URL is correct |
平台不支持 |
Non-Chinese site | This Skill only supports Chinese news sites |
提取失败 |
Network error or page structure change | Retry or check URL validity |
Notes
- For educational and research purposes only
- Do not perform large-scale crawling
- Respect the target website's robots.txt and terms of service
- WeChat Official Accounts may require a valid Cookie (the current default configuration usually works)
Directory Structure
china-news-crawler/
├── SKILL.md # [必需] Skill 定义文件
├── 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 # 腾讯新闻