做过舆情监控或数据分析的人大多会遇到类似需求:
- 想定时抓取 微博热榜,观察哪些话题在升温;
- 或者需要监控 小红书的热门笔记,看看某个关键词下大家都在讨论什么。
一开始很多人用单机脚本就能跑通,但随着监控范围扩大,话题数和评论量成倍增加,往往就得考虑分布式架构。
常见做法:单机采集微博热榜
最简单的尝试就是写一个多线程脚本,把微博热搜前几十个话题抓下来:
import requests
from concurrent.futures import ThreadPoolExecutor
urls = [f"https://s.weibo.com/top/summary?cate=realtimehot&page={
i}" for i in range(1, 6)]
def fetch(url):
resp = requests.get(url, timeout=5)
return resp.text
with ThreadPoolExecutor(max_workers=20) as executor:
results = list(executor.


最低0.47元/天 解锁文章
810

被折叠的 条评论
为什么被折叠?



