关键词搜索
通过关键词在所需的小时日时间范围内搜索微博帖子,支持基于页码的分页、热门或时间排序,以及图片、视频、音乐或链接的筛选。用于查找有时间限制的帖子,以进行话题研究或监控。
参数
| 参数 | 必填 | 类型 | 说明 | 示例 | 可选值 |
|---|---|---|---|---|---|
q |
必填 | string | 搜索关键词。 | 咖啡 |
— |
start_day |
必填 | string | 开始日期 (yyyy-MM-dd)。 | 2026-11-17 |
— |
start_hour |
必填 | integer | 起始小时(0-23)。 | 0 |
— |
end_day |
必填 | string | 结束日期 (yyyy-MM-dd)。 | 2026-11-23 |
— |
end_hour |
必填 | integer | 结束小时(0-23)。 | 23 |
— |
hot_sort |
可选 | boolean | 热门排序,true 表示热门排序,false 表示时间排序。默认为 false。 | False |
— |
contains |
可选 | string | 包含结果集的过滤器。 可用值: - `ALL`: 全部 - `PICTURE`: 包含图片 - `VIDEO`: 包含视频 - `MUSIC`: 包含音乐 - `LINK`: 包含链接 | ALL |
ALLPICTUREVIDEOMUSICLINK |
page |
可选 | integer | 页码,从1开始。 | 1 |
— |
代码示例
curl -G "https://api.mofa-ai.com/v1/weibo/search_all_v2" \
-H "Authorization: Bearer $MOFA_API_KEY" \
--data-urlencode 'q=咖啡' \
--data-urlencode 'start_day=2026-11-17' \
--data-urlencode 'start_hour=0' \
--data-urlencode 'end_day=2026-11-23' \
--data-urlencode 'end_hour=23' \
--data-urlencode 'hot_sort=False' \
--data-urlencode 'contains=ALL' \
--data-urlencode 'page=1'
import os
import requests
resp = requests.get(
"https://api.mofa-ai.com/v1/weibo/search_all_v2",
headers={"Authorization": f"Bearer {os.environ['MOFA_API_KEY']}"},
params={
"q": "咖啡",
"start_day": "2026-11-17",
"start_hour": "0",
"end_day": "2026-11-23",
"end_hour": "23",
"hot_sort": "False",
"contains": "ALL",
"page": "1",
},
timeout=60,
)
body = resp.json()
if body["success"]:
print(body["cost_usd"], body["data"])
else:
print(body["error"], body["message"])
const url = new URL("https://api.mofa-ai.com/v1/weibo/search_all_v2");
url.search = new URLSearchParams({
q: "咖啡",
start_day: "2026-11-17",
start_hour: "0",
end_day: "2026-11-23",
end_hour: "23",
hot_sort: "False",
contains: "ALL",
page: "1",
});
const resp = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.MOFA_API_KEY}` },
});
const body = await resp.json();
if (body.success) console.log(body.cost_usd, body.data);
else console.error(body.error, body.message);
在线试用
登录后可以在这里直接调用此接口,按价格从余额扣费,失败不收费。新账户赠送 $0.50 试用额度。
响应示例
这个接口暂无响应示例。