技能标识:china-news
中国新闻资讯聚合工具。Use when user wants to get latest news from Chinese sources. Supports multiple news sites (Sina, Sohu, NetEase, Tencent) via browser automation and RSS. Generates categorized news reports. 新闻资讯、热点新闻、每日新闻。
中国新闻资讯聚合工具,通过浏览器自动化和RSS订阅获取各大新闻网站内容,生成分类新闻报告。
| 来源 | 网址 | 内容 |
|---|---|---|
| 新浪新闻 | news.sina.com.cn | 综合新闻 |
| 搜狐新闻 |
| 来源 | RSS地址 | 内容 |
|---|---|---|
| 新浪新闻 | rss.sina.com.cn | 综合 |
| 搜狐新闻 |
检测浏览器是否可用
↓
可用 → 浏览器模式(更丰富)
↓
不可用 → 自动降级到RSS模式(默认)
python
def checkbrowseravailable():
检测浏览器是否可用
try:
# 尝试调用浏览器
# 如果OpenClaw配置了browser工具且浏览器可用
return True
except:
return False
def getnewssources():
根据环境自动选择获取方式
if checkbrowseravailable():
# 浏览器模式:获取更丰富的新闻
print(🌐 使用浏览器模式)
return {
mode: browser,
sources: [
{name: 新浪新闻, url: https://news.sina.com.cn},
{name: 搜狐新闻, url: https://news.sohu.com},
{name: 网易新闻, url: https://news.163.com},
]
}
else:
# RSS模式(默认):轻量快速,无需浏览器
print(📡 浏览器不可用,使用RSS模式)
return {
mode: rss,
sources: [
{name: 36氪, url: https://36kr.com/feed},
{name: 搜狐新闻, url: https://news.sohu.com/rss/},
]
}
| 环境 | 模式 | 新闻来源 | 数据丰富度 |
|---|---|---|---|
| 有浏览器 | 浏览器模式 | 新浪/搜狐/网易 | ⭐⭐⭐⭐⭐ |
| 无浏览器 |
RSS模式完全可用,无需浏览器即可获取新闻
javascript
// 打开新闻网站
await browser.open({
url: https://news.sina.com.cn
})
// 等待加载
await browser.wait({ timeout: 5000 })
// 提取新闻标题和链接
const news = await browser.evaluate(() => {
const items = []
// 提取各类新闻区块
document.querySelectorAll(a).forEach(el => {
const text = el.innerText?.trim()
if (text && text.length > 10 && text.length < 100) {
// 过滤掉导航、广告等
if (!text.includes(登录) && !text.includes(注册) &&
!el.href.includes(javascript:) && el.href.startsWith(http)) {
items.push({
title: text,
url: el.href,
source: 新浪
})
}
}
})
return items.slice(0, 20)
})
python
import requests
import xml.etree.ElementTree as ET
def fetchrss(url, sourcename):
获取RSS订阅内容
try:
response = requests.get(url, timeout=10, headers={
User-Agent: Mozilla/5.0
})
root = ET.fromstring(response.content)
items = []
for item in root.findall(.//item):
title = item.find(title)
link = item.find(link)
if title is not None and title.text:
items.append({
title: title.text.strip(),
url: link.text if link is not None else ,
source: source_name
})
return items[:15]
except:
return []
python
def categorizenews(newslist):
智能分类新闻
categories = {
时事: [政治, 国际, 外交, 政策, 政府, 两会, 选举],
财经: [股市, 基金, 经济, 金融, 投资, 银行, 房产],
科技: [AI, 人工智能, 芯片, 手机, 互联网, 新能源],
体育: [足球, 篮球, 奥运, 世界杯, NBA, 中超],
娱乐: [明星, 电影, 音乐, 综艺, 八卦, 热播],
社会: [事故, 案件, 民生, 教育, 医疗, 疫情]
}
categorized = {cat: [] for cat in categories}
categorized[其他] = []
for news in news_list:
matched = False
for category, keywords in categories.items():
if any(kw in news[title] for kw in keywords):
categorized[category].append(news)
matched = True
break
if not matched:
categorized[其他].append(news)
# 移除空分类
return {k: v for k, v in categorized.items() if v}
python
def generatenewsreport(categorizednews, datestr):
生成精美新闻报告
output = []
output.append(f┌{─*50}┐)
output.append(f│ 📰 每日新闻速递)
output.append(f│ {date_str})
output.append(f└{─*50}┘)
output.append()
# 热点速递(取每个分类的第一条)
output.append(🔥 热点速递)
output.append(─ * 40)
for category, newslist in categorizednews.items():
if news_list and category != 其他:
topnews = newslist[0]
output.append(f【{category}】{top_news[title]})
output.append()
# 分类详情
for category, newslist in categorizednews.items():
if news_list:
output.append(f📌 {category}新闻)
output.append(─ * 40)
for i, news in enumerate(news_list[:5], 1):
output.append(f{i}. {news[title]})
if news.get(source):
output.append(f 来源:{news[source]})
output.append()
return \n.join(output)
bash
python3 << PYEOF
import os
import requests
import xml.etree.ElementTree as ET
from datetime import datetime
class ChinaNews:
def init(self):
self.rss_sources = {
新浪国内: https://rss.sina.com.cn/news/china/roll.xml,
新浪国际: https://rss.sina.com.cn/news/world/roll.xml,
新浪财经: https://rss.sina.com.cn/finance/roll.xml,
新浪科技: https://rss.sina.com.cn/tech/roll.xml,
搜狐新闻: https://news.sohu.com/rss/
}
self.keywords = {
时事: [政治, 国际, 外交, 政策, 政府, 两会, 外交],
财经: [股市, 基金, 经济, 金融, 投资, 银行, 房产, A股],
科技:
以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:
帮我安装 SkillHub 和 china-news-1776027182 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 china-news-1776027182 技能
skillhub install china-news-1776027182
文件大小: 5.55 KB | 发布时间: 2026-4-13 09:42