跳到导航

微信搜一搜怎么只找公众号文章,并整理最近一周的选题?

用 wechat_search.v2.fetch_search 搜索,设置 business_type:"article",结果只返回公众号文章,不会混进视频号视频。要最近一周,加 publish_time:"week";要按最新排序,加 sort:"latest"。例如做招聘信息整理,先搜“招聘”,看结果卡片,挑出值得读的文章,再去取这些文章的正文。

先把要找的内容说清楚

可以给已接好 BeatAPI 的助手这样的任务:

在微信搜一搜搜“招聘”,只要最近一周的公众号文章,按最新排序。先检查最多3页结果,挑出与上海产品经理岗位相关的文章,保留可核对的来源链接;再告诉我哪些值得读正文。

“上海产品经理”是你的相关性判断,不是搜索参数。把检索词拆成更具体的几组分别搜索,返回后逐条核对招聘城市、岗位和截止时间。确实相关或信息不完整的文章,再读正文。

直接发起文章搜索

data:wechat_search.v2.fetch_search 的请求示例:

curl -sS https://api.beatapi.io/v1/social-data/call \
-H "Authorization: Bearer $BEATAPI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"action":"wechat_search.v2.fetch_search","params":{"keyword":"招聘","business_type":"article","publish_time":"week","sort":"latest","offset":0,"raw":false}}' \
-o wechat-article-search.json

常用设置按目的选择:

你要做什么设置
跟踪今天的新消息publish_time:"day"、sort:"latest"
整理最近一周的内容publish_time:"week"、sort:"latest"
找更相关的候选文章sort:"default"
找按点赞热度排序的候选sort:"hot"

publish_time 还支持 half_year 和 all。sort:"hot" 按点赞找热门候选,行业阅读量排名需要另外的数据与比较口径。搜索账号用 business_type:"account",搜索视频用 "video"。

有下一页,怎么继续?

  1. 首页传 offset:0。
  2. 取下一页时,检索词、publish_time 和 sort 保持不变,把返回的 data.cursor 原样带入下一次请求。
  3. 用 data.continue_flag 判断是否还有下一页。

只把 offset 改成 20,返回的还是第一页。

显式 raw:false 时,结果在 data.items。data.count 是本页数量,data.total 是搜索盒子报告数量的最大值,不能直接当去重文章总数。做“最多 3 页”的任务,报告实际保存了几页、收集了多少条候选观察。

搜完后怎样变成能用的清单?

  1. 逐张核对结果卡片,记下能确认的标题、来源、时间和文章链接。
  2. 写一句入选理由,例如“岗位和城市符合,需读正文确认投递截止时间”。
  3. 与目标无关的招聘培训和过时的转载,移到排除清单。
  4. 只为入选的文章取正文,按正文读取流程操作;想长期追踪某个账号,接这个账号的账号文章列表。

下方的 search_archive.py 保存原始结果卡片。search_archive.py 不提取文章标题和 URL,也不把它们交给正文读取,因为卡片到文章的映射还没核实。search_archive.py 的产物用来保存和复核搜索结果;候选清单由你或助手逐条编辑。

例如查「上海 前端 招聘」时,首批结果里有一篇招聘原文和一篇转发。用能确认的原文链接整理候选,在转发旁注明它指向哪篇原文。核对岗位、城市和截止日期后,再把候选交给同事。只有搜索摘要、没取得正文的行,标「待确认截止日期」。

可选:保存本次搜索档案

把1–3页真实请求与响应放在同一目录,建立 manifest.json:

[{"action":"wechat_search.v2.fetch_search","params":{"keyword":"招聘","business_type":"article","publish_time":"week","sort":"latest","offset":0,"raw":false},"http_status":200,"collected_at":"2026-11-17T03:00:00+08:00","response_file":"wechat-article-search.json"}]

把下面的 Python 脚本保存为 search_archive.py,运行 python3 search_archive.py manifest.json search-run-01。search_archive.py 在本地生成 items.jsonl、coverage.json 和原响应副本,记录每条的页码、位置、请求 ID 和采集时间;输出目录已存在时脚本停止,不覆盖。

import hashlib, json, pathlib, sys
from datetime import datetime
manifest, target = map(pathlib.Path, sys.argv[1:3])
entries = json.loads(manifest.read_text(encoding='utf-8'))
if not isinstance(entries, list) or not 1 <= len(entries) <= 3:
raise ValueError('Supply 1–3 saved pages; this helper makes no requests')
action = 'wechat_search.v2.fetch_search'
items, sources, blobs, seen, request_ids = [], [], [], set(), set()
base, expected, previous_time, stop = None, None, None, 'saved_pages_end'
for n, entry in enumerate(entries, 1):
p = entry['params']
if entry['action'] != action or p.get('business_type') != 'article' or p.get('raw') is not False:
raise ValueError('Use article with explicit raw=false')
if set(p) - {'keyword','business_type','publish_time','sort','offset','cursor','raw'}:
raise ValueError('Unexpected parameter')
if p.get('publish_time') != 'week' or p.get('sort') != 'latest' or type(p.get('offset')) is not int or p['offset'] != 0:
raise ValueError('This workflow uses week/latest/offset=0 throughout')
if not isinstance(p.get('keyword'), str) or not 1 <= len(p['keyword'].strip()) <= 100:
raise ValueError('Invalid keyword')
core = {k:v for k,v in p.items() if k != 'cursor'}
if base is None: base = core
if core != base or (n == 1 and p.get('cursor') not in (None,'')) or (n > 1 and p.get('cursor') != expected):
raise ValueError('Query changed or cursor chain broken')
ts = datetime.fromisoformat(entry['collected_at'].replace('Z','+00:00'))
if ts.tzinfo is None or (previous_time is not None and ts < previous_time):
raise ValueError('Use chronological timezone-aware collection times')
previous_time = ts
status = entry['http_status']
if type(status) is not int or not 100 <= status <= 599: raise ValueError('Invalid HTTP status')
raw = (manifest.parent / entry['response_file']).read_bytes()
body = json.loads(raw)
if not isinstance(body, dict): raise ValueError('Expected gateway object')
error = body.get('error')
ok = status == 200 and body.get('status') == 'succeeded' and not error
if not ok and not (isinstance(error,dict) and isinstance(error.get('code'),str) and error['code'].strip()):
raise ValueError('Malformed or unrecognized failure envelope')
rid = body.get('request_id') or (error.get('request_id') if isinstance(error,dict) else None)
if ok and (body.get('action') != action or not isinstance(rid,str) or not rid or rid in request_ids):
raise ValueError('Mismatched action or missing/repeated request ID')
if ok: request_ids.add(rid)
raw_name = 'raw-%03d.json' % n
record = {'page':n,'request_id':rid,'params':p,'collected_at':entry['collected_at'],
'http_status':status,'error_code':error.get('code') if isinstance(error,dict) else None,'raw_file':raw_name,'sha256':hashlib.sha256(raw).hexdigest()}
blobs.append((raw_name, raw)); sources.append(record)
if not ok:
stop = 'gateway_failed'
else:
data = body.get('data')
if not isinstance(data,dict) or not isinstance(data.get('items'),list) or not all(isinstance(x,dict) for x in data['items']):
raise ValueError('Expected data.items object array')
if data.get('keyword') != p['keyword'].strip(): raise ValueError('Keyword echo mismatch')
vertical = data.get('business_type')
if (isinstance(vertical,str) and vertical != 'article') or vertical == 33554499:
raise ValueError('Response explicitly reports a non-article vertical')
record.update({k:data.get(k) for k in ('count','total','business_type','no_more','continue_flag','cursor','offset')})
for i,item in enumerate(data['items']):
items.append({'page':n,'item_index':i,'request_id':rid,'item':item})
more, cursor = data.get('continue_flag'), data.get('cursor')
if more is False or (type(more) is int and more == 0): stop = 'provider_end'
elif not (more is True or (type(more) is int and more == 1)): stop = 'unsupported_more_flag'
elif not data['items']: stop = 'empty_page_with_more'
elif not isinstance(cursor,str) or not cursor: stop = 'missing_cursor'
elif cursor in seen: stop = 'repeated_cursor'
else:
seen.add(cursor); expected = cursor; stop = 'saved_pages_end'
if stop != 'saved_pages_end' and n != len(entries):
raise ValueError('Manifest continues after a terminal or invalid page')
if stop == 'saved_pages_end' and len(entries) == 3: stop = 'helper_page_cap'
report = {'query':base,'pages_saved':len(entries),'item_observations':len(items),
'stop_reason':stop,'complete_search':False,'deduplicated_articles':False,'sources':sources}
target.mkdir(parents=True,exist_ok=False)
for name,raw in blobs: (target/name).write_bytes(raw)
(target/'items.jsonl').write_text(''.join(json.dumps(x,ensure_ascii=False)+'\n' for x in items),encoding='utf-8')
(target/'coverage.json').write_text(json.dumps(report,ensure_ascii=False,indent=2),encoding='utf-8')
if stop == 'saved_pages_end':
(target/'next-request.json').write_text(json.dumps({'action':action,'params':{**base,'cursor':expected}},ensure_ascii=False,indent=2),encoding='utf-8')
print(json.dumps({'pages_saved':len(entries),'item_observations':len(items),'stop_reason':stop}))

先看 coverage.json 里的停止原因和实际页数,再核对 items.jsonl。同一张卡片出现两次就记两条观察,条目数是观察数量。search_archive.py 不接受 raw:true 返回的 data.results 结构;账号卡片的 jumpInfo.userName 也不能当作文章所属账号的标识。

当前搜索价格见价格页;正文和统计是另外的请求,按实际使用计费。整理清单时直接复核已保存的结果,不必重新搜索。

公众号问题目录