Quack! This duck scans it all for you in one goXiaohongshu, Douyin, WeChat Official AccountsA-share discussions on these platforms—with a built-in set of core A-share keywords and a default of the last 7 days, view stock market public opinion across all three platforms at once: what retail investors are talking about, what hot topics self-media are chasing, and what in-depth accounts are reviewing. After-market review and sentiment monitoring, all laid out with one command.
Data goes through doubaoya.com a single line, authentication uses your own token (environment variable
DOUBAOYA_API_KEY, in the formdyh_…)。
Use cases
| Scenario | How to use | What you get |
|---|---|---|
| Daily stock market public opinion | Run directly (without keywords), scans the built-in core A-share terms | Grasp stock market trends across three platforms at once |
| After-market / weekly review | --days 7 View the discussion accumulation over the past week |
Which theme is continuously fermenting |
| Targeted theme tracking | Pass a keyword such as 半导体、券商 |
Focus on cross-platform discussions of a single theme |
| Sentiment monitoring | Compare the scope and popularity across the three platforms | Retail sentiment vs self-media follow-up commentary vs in-depth review |
Platform signal quick read: Xiaohongshu = retail sharing / stock trading insights; Douyin = intraday quick commentary / limit-up interpretation / sentiment propagation; WeChat Official Accounts = in-depth review / strategy research reports. Cross-validation across the three platforms is the most reliable.
Workflow (4 steps)
1. Decide what to query
- Default (without keywords): the script automatically iterates through the built-in core A-share keywords and queries them one by one—zero configuration, ready to use, suitable for daily public opinion scanning.
- Targeted (with keywords): if the user explicitly gives a theme (such as
半导体、新能源、券商), pass it as a positional argument to query only that one term. - By default it looks back over the past 7 days; if the user wants a different scope, use
--days Nto override.
Built-in keywords:A股、大盘、涨停、选股、牛市、券商、北交所、科创板、题材股、龙头股、加仓、复盘。
2. Call the script
# 默认:遍历内置 A股关键词,近7天
python3 "$SKILL_PATH/scripts/fetch_astock_feed.py"
# 定向题材:
python3 "$SKILL_PATH/scripts/fetch_astock_feed.py" "半导体"
# 自定义回溯天数:
python3 "$SKILL_PATH/scripts/fetch_astock_feed.py" "券商" --days 3
The script outputs the result as JSON to stdout, with the structure {"range": {...}, "results": { 关键词: data, ... }}, each data containing three arrays. When iterating over multiple terms,one script call is enough, do not repeatedly run the same set of terms; read the complete stdout directly, do not use head / tail。
3. Render the three-platform table
For each keyword's data contains three arrays (read defensively; leave blank if fields are missing, do not error):
| Array key | Platform | Typical fields |
|---|---|---|
xhsResult |
Xiaohongshu | title / authorName / likeCount / commentCount / publishTime / link |
dyResult |
Douyin | title / authorName / likes / comments / shares / publishTime / link |
gzhResult |
WeChat Official Accounts | title / accountName / reads / likes / publishTime / link |
Display method: Lay out tables by platform in the order WeChat Official Account → Xiaohongshu → Douyin, or merge them into one 平台 / 标题 / 互动 / 发布时间 table for horizontal comparison. When there are multiple keywords, you can group by topic, giving a three-platform quick overview for each section. Render titles as clickable links.
4. Give a one-sentence review insight
After the table, add one sentence in this Duck's toneStock market public opinion insights: which topic is heating up on all three platforms at the same time, whether retail sentiment is more bullish or bearish, and what risks in-depth accounts are flagging. Keep it short and useful, without piling on clichés.
⚠️ This Duck only relays public social media discussion data and does not constitute any investment advice; interaction counts are snapshots at collection time and may still be changing.
Get the key (token)
- Open doubaoya.com
- Log in(register first if you don't have an account)
- Go to Token Center
- Generate token(in the form
dyh_…)
Configure it into an environment variable (the script only recognizes this):
export DOUBAOYA_API_KEY="dyh_你的口令"
Iron rule: never print the token, never write it to a file, never echo it back to the user. The script itself also never outputs the token. All requests are sent only to doubaoya.com, and the token must not be taken to any other domain.
Dependencies: uses only the Python 3 standard library, no third-party packages need to be installed.
API and envelope
POST https://doubaoya.com/api/apis/multi/cn30-multi-search/call(the same aggregation API as "All-Network Works Aggregation for the Last 30 Days", thematized here as A-shares)- Auth header:
Authorization: Bearer $DOUBAOYA_API_KEY - Request body (one per keyword):
{ "keyword": "...", "startDate": "YYYY-MM-DD", "endDate": "YYYY-MM-DD" }keyword: string, requiredstartDate/endDate: the script automatically calculates it from--days(endDate= today,startDate= today - days)
- Return envelope:
{ "success": true, "requestId": "...", "data": { "xhsResult": [ { "title": "...", "authorName": "...", "publishTime": "..." } ], "dyResult": [ { "title": "...", "authorName": "...", "publishTime": "..." } ], "gzhResult": [ { "title": "...", "accountName": "...", "publishTime": "..." } ] }, "error": null } - First check
success: only when it istrueshould you readdata; otherwise readerror.code/error.message。 - Field defensiveness: field names in the three arrays may differ slightly and may be missing; always "use a default value if unavailable".
Error handling
When the script fails for any keyword, it prints to stderr [error] CODE: message(关键词「…」); when iterating over multiple words, failure of a single word does not affect the others,only when all keywords faildoes it exit with exit code 1 (successful words still go into results, and failed words go into errors). Common cases:
| HTTP | code | Meaning | Handling |
|---|---|---|---|
| 401 | MISSING_API_KEY / UNAUTHORIZED |
No token provided or token invalid | Check DOUBAOYA_API_KEY, go to the Token Center to regenerate it (do not echo the token) |
| 400 | VALIDATION_ERROR |
Invalid parameter | Correct the parameter and retry |
| 402 | INSUFFICIENT_CREDITS |
Insufficient quota | Go to doubaoya.com to top up / renew quota |
| 404 | ENDPOINT_NOT_FOUND |
Incorrect API path | Usually this means the script has been modified; restore the default endpoint path |
| 502 | PROVIDER_FAILED |
Temporary upstream failure (automatically refunded) | Safe to retry |
| — | NETWORK_ERROR |
Cannot connect to doubaoya.com | Check the network and retry |
502 PROVIDER_FAILEDwill automatically refund; retrying is safe and will not result in duplicate charges.
Directory structure
astock-social-feed/
├── SKILL.md # 本文件
└── scripts/
└── fetch_astock_feed.py # 零依赖脚本(urllib + datetime),调用 doubaoya.com