Credential configuration
API keys, tokens, and cookies are uniformly recommended to be written in the repository root directory .env(refer to .env.example), and loaded by the runtime or the user as environment variables with the same names before execution. Scripts still only read credentials from environment variables or explicit CLI parameters; do not write real keys into skill payloads, reports, logs, or commits.
The script searches three Chinese social platforms: Bilibili, Zhihu, and Douyin. Xiaohongshu and Weibo currently have no available script entry points. If the research must cover these two types of sources, use browser-use to open public web page results or platform search pages, and state in the results that the source comes from a web page fallback.
Stability notes
Chinese social platforms do not have stable public search APIs. All scripts rely on internal APIs or third-party libraries,and may fail due to platform updates。
| Script | Platform | Stability | Authentication method |
|---|---|---|---|
bilibili_search.py |
Bilibili | Relatively high | Not required (optional cookie improves quality) |
zhihu_search.py |
Zhihu | Medium | Requires ZHIHU_COOKIE |
douyin_search.py |
Douyin | Relatively low | Requires DOUYIN_COOKIE |
| No script | Xiaohongshu | Low | browser-use / public web page fallback |
| No script | Low | browser-use / public web page fallback |
Dependencies
On first run or when the script prompts that a library is missing, use this skill's dependency list to install into the current Python environment:
python3 -m pip install -r requirements.txt
Do not automatically install dependencies inside the script. If installation fails, the network is unavailable, or the package is unavailable, stop using the corresponding script and switch to browser-use to search freely visible web pages, and explain that dependencies are missing.
How to obtain cookies
- Log in to the corresponding script platform in the browser
- Open developer tools (F12) → Network tab
- Refresh the page and find in the request headers the
Cookiefield - Set the complete cookie string as the corresponding environment variable. Xiaohongshu and Weibo currently have no script entry points and do not read
XHS_COOKIE/WEIBO_COOKIE。
Parameter description
bilibili_search.py
python3 scripts/bilibili_search.py <query> [选项]
| Parameter | Description | Default value |
|---|---|---|
query |
Search keyword (required) | — |
--limit, -n |
Number of results to return | 10 |
--cookie |
Bilibili Cookie (can also be set via the BILIBILI_COOKIE environment variable, optional, improves result quality) |
— |
--order |
Sorting: empty=comprehensive, totalrank=best match, click=plays, pubdate=latest, dm=danmaku, stow=favorites |
Comprehensive |
python3 scripts/bilibili_search.py "机器学习教程" --limit 5
python3 scripts/bilibili_search.py "Python" --order click --limit 10
zhihu_search.py
python3 scripts/zhihu_search.py <query> [选项]
| Parameter | Description | Default value |
|---|---|---|
query |
Search keyword (required) | — |
--limit, -n |
Number of results to return | 10 |
--cookie |
Zhihu Cookie (can also be set via the ZHIHU_COOKIE environment variable, required) |
— |
--type |
Search type:general, topic, people, zvideo |
general |
ZHIHU_COOKIE="..." python3 scripts/zhihu_search.py "Python 异步编程" --limit 5
python3 scripts/zhihu_search.py "大模型" --cookie "..." --type topic --limit 5
douyin_search.py
python3 scripts/douyin_search.py <query> [选项]
| Parameter | Description | Default value |
|---|---|---|
query |
Search keyword (required) | — |
--limit, -n |
Number of results to return | 10 |
--cookie |
Douyin Cookie (can also be set via DOUYIN_COOKIE environment variable, required) |
— |
DOUYIN_COOKIE="..." python3 scripts/douyin_search.py "编程教程" --limit 5
Output format
Standard JSON:{"success": true, "query": "...", "provider": "bilibili|zhihu|douyin", "items": [...], "error": null}
When Xiaohongshu and Weibo fall back to browser-use / public web pages, the above script JSON structure is not guaranteed; just record the opened page URL, search terms, visible results, and limitations.