python3 scripts/hot.py # 全部源
python3 scripts/hot.py weibo --limit 30 # 单个源
python3 scripts/hot.py --json # 给机器读
── weibo ──
1. C罗宣布结婚 (1,158,817)
https://s.weibo.com/weibo?q=%23C罗宣布结婚%23
── bilibili ──
1. 《影之刃零》预购开启,11分钟实机预告公开 (2,526,863)
https://b23.tv/BV1Hmuv68EWW
--json Each entry gives {source, title, heat, url, extra};extra.rank isthe platform's original rank
(after dropping empty entries, ranks are not renumbered, otherwise the reported ranks won't match the platform). Exit code 0 at least one source succeeded / 1 all failed.
| Source | What it pulls | API |
|---|---|---|
weibo |
Hot search list (~50 entries) | weibo.com/ajax/side/hotSearch |
bilibili |
Popular video list | api.bilibili.com/x/web-interface/popular |
How to use these trends
The trending lists give youtopic words and titles, not content you can directly publish. Typical usage:
- Pull trending lists → a person or model picks out the ones related to your own category
- After getting the topic word, godig deeper:
xiaohongshu-scraper/douyin-scrapersee how others write under this word,bilibili-creator-finderfind UP creators in this direction - Materials need to be saved for reuse →
oss-upload
Don't directly use hot search words as topics. A large portion of hot searches are social news and celebrity gossip; forcibly riding them against your brand tone will backfire;
heat being high only means high traffic, not that it suits you.
Adding new platforms
Just add a fetcher to SOURCES ,don't branch inside the caller. Fetcher contract:
fetch_xxx(limit, get_json=None) -> [{source, title, heat, url, extra}], throw if it can't pull HotError。
Pitfalls
- Raw Weibo call returns 403: you must first visit
weibo.comto get a guest cookie, then call the API with the same cookie jar. The code already does this, don't "optimize" this layer away. - Referer must be given per source: the Bilibili API returns 403 directly when it receives Weibo's Referer. Don't make a "generic HTTP client" that unifies headers — this skill has been burned by that.
- The APIs are public and unofficial, the platform may change them at any time. If it's down, it's down,
fail-closedthrow an error,don't degrade to silently returning an empty list — an empty list and a failed fetch are two different things. - Read-only public data, no login, no account cookies.Don't attach a logged-in session just to pull more data, that's a different risk level.
Related
aihot is a dedicated trending list for AI industry news (another data source); this skill is a general social media trending list.