← 返回 Skills 市场
dustink66

IT之家 日榜/周榜/月榜 热门文章

作者 尘墨成 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ pending
34
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install ithome-rank
功能描述
Use this skill when you need to fetch IT之家 (ithome.com) daily/weekly/monthly hot/ranking articles and push them to a messaging channel (WeChat, QQ, DingTalk,...
使用说明 (SKILL.md)

Prerequisites

  • Python 3 with requests library installed
  • Network access to https://www.ithome.com/
  • (Optional) QwenPaw cron and channel-send capabilities for scheduled push

Script Location

The Python script is expected at:

scripts/ithome_rank.py

relative to the workspace root.


1. Create the Python fetch script

Create scripts/ithome_rank.py with the following content:

#!/usr/bin/env python3
"""抓取 IT之家 日榜/周榜/月榜 热门文章"""
import requests, re, sys
from datetime import date

def fetch_rank(rank_type="日榜"):
    headers = {
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
                      "AppleWebKit/537.36 (KHTML, like Gecko) "
                      "Chrome/120.0.0.0 Safari/537.36"
    }
    r = requests.get("https://www.ithome.com/", headers=headers, timeout=15)
    r.encoding = "utf-8"
    html = r.text

    # 先找到 rank 区域(避免匹配到页面中其他 id="d-X" 的元素)
    rank_start = html.find('\x3Cdiv id="rank"')
    if rank_start == -1:
        return []
    rank_end = html.find('\x3C/div>', html.find('\x3C/div>', html.find('\x3C/div>', rank_start) + 1) + 1) + 6
    rank_html = html[rank_start:rank_end]

    type_map = {"日榜": "1", "周榜": "2", "月榜": "3"}
    data_id = type_map.get(rank_type, "1")

    pattern = rf'id="d-{data_id}"[^>]*>(.*?)\x3C/ul>'
    match = re.search(pattern, rank_html, re.DOTALL)
    if not match:
        return []

    items_html = match.group(1)
    links = re.findall(
        r'\x3Ca[^>]*title="([^"]*)"[^>]*href="([^"]*)"[^>]*>',
        items_html
    )
    return links


def format_message(articles, rank_name="日榜"):
    today = date.today()
    month, day = today.month, today.day
    lines = [f"📰 IT之家{rank_name}热门 — {month}月{day}日"]
    lines.append("━" * 20)
    if not articles:
        lines.append("(暂无数据)")
    else:
        for i, (title, url) in enumerate(articles, 1):
            lines.append(f"{i}. 🔥 [{title}]({url})")
    lines.append("")
    lines.append("_来源:IT之家_")
    return "\
".join(lines)


if __name__ == "__main__":
    rank_type = sys.argv[1] if len(sys.argv) > 1 else "日榜"
    articles = fetch_rank(rank_type)
    print(format_message(articles, rank_type))

Why this approach (no browser): The server likely doesn't have Chrome/Chromium installed, so browser_use will fail. Using requests to fetch the HTML directly is more reliable and faster.

Key parsing detail: The IT之家 homepage has two id="d-1" elements — the first is a software download section, the second (inside \x3Cdiv id="rank">) contains the actual rank articles. Always locate the rank div first before extracting the article list.

2. Run the script and get formatted output

# 日榜(默认)
python3 scripts/ithome_rank.py 日榜

# 周榜
python3 scripts/ithome_rank.py 周榜

# 月榜
python3 scripts/ithome_rank.py 月榜

Expected output format (markdown):

📰 IT之家日榜热门 — 6月17日
━━━━━━━━━━━━━━━━━━━━
1. 🔥 [标题](链接)
2. 🔥 [标题](链接)
...
_来源:IT之家_

The 日榜 returns 12 articles.

3. Push the result to a messaging channel

First query the target session:

qwenpaw chats list --agent-id \x3Cagent_id> --channel \x3Cchannel>

Then send:

qwenpaw channels send \
  --agent-id \x3Cagent_id> \
  --channel \x3Cchannel> \
  --target-user \x3Cuser_id> \
  --target-session \x3Csession_id> \
  --text "$(python3 scripts/ithome_rank.py 日榜)"

4. (Optional) Set up daily scheduled push

qwenpaw cron create \
  --agent-id \x3Cagent_id> \
  --type agent \
  --schedule-type cron \
  --name "IT之家日榜推送" \
  --cron "0 9 * * *" \
  --channel wechat \
  --target-user \x3Cuser_id> \
  --target-session \x3Csession_id> \
  --text "请运行命令 python3 scripts/ithome_rank.py 日榜 并将输出结果推送给我" \
  --timeout 120 \
  --timezone Asia/Shanghai \
  --mode final

Failure Modes and Recovery

Problem Symptom Fix
No Chrome/Chromium browser_use fails Use requests approach instead (this skill's default)
Wrong content extracted Gets 最会买/要知 download links Ensure rank div is located first before extracting list
Network unreachable requests.get times out Check proxy / network settings
HTML structure changed Regex doesn't match Inspect page source and update regex
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install ithome-rank
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /ithome-rank 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of ithome-rank skill for fetching IT之家 (ithome.com) daily, weekly, or monthly hot/ranking articles. - Provides a Python script using `requests` (no browser required) to reliably parse and format top articles for easy retrieval. - Supports scheduled or on-demand article list pushes to common messaging channels (WeChat, QQ, DingTalk, Feishu, etc.). - Includes detailed setup, usage, and troubleshooting instructions for pushing news and scheduling daily updates.
元数据
Slug ithome-rank
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

IT之家 日榜/周榜/月榜 热门文章 是什么?

Use this skill when you need to fetch IT之家 (ithome.com) daily/weekly/monthly hot/ranking articles and push them to a messaging channel (WeChat, QQ, DingTalk,... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 34 次。

如何安装 IT之家 日榜/周榜/月榜 热门文章?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install ithome-rank」即可一键安装,无需额外配置。

IT之家 日榜/周榜/月榜 热门文章 是免费的吗?

是的,IT之家 日榜/周榜/月榜 热门文章 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

IT之家 日榜/周榜/月榜 热门文章 支持哪些平台?

IT之家 日榜/周榜/月榜 热门文章 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 IT之家 日榜/周榜/月榜 热门文章?

由 尘墨成(@dustink66)开发并维护,当前版本 v1.0.0。

💬 留言讨论