fix(xueqiu): fix 400 errors by using browser cookies and correct headers
The Xueqiu stock API requires a login session token (xq_a_token) that is generated by Xueqiu's frontend JavaScript and cannot be obtained by simply visiting the homepage. This caused persistent HTTP 400 (error code 400016) for all users. Changes: - _ensure_cookies(): add three-level priority — config file (saved by --from-browser) → live Chrome cookies via browser_cookie3 → homepage fallback. The homepage-only approach only ever got acw_tc (anti-DDoS token), never xq_a_token. - _get_json(): switch User-Agent from "agent-reach/1.0" to a real Chrome UA, and add Referer: https://xueqiu.com/ to all API requests. - get_hot_posts(): replace the defunct /statuses/hot/listV3.json endpoint (returns empty body) with the v4 public timeline endpoint; correctly parse item.data as a JSON string to extract author, text, and likes. - cookie_extract.py: add Xueqiu to PLATFORM_SPECS and configure_from_browser so that `agent-reach configure --from-browser chrome` now also saves Xueqiu cookies (only when xq_a_token is present). - check(): improve error message to direct users to --from-browser instead of suggesting a proxy. - Fix urllib.parse.quote usage (was using urllib.request.quote). - Update tier and backends description to reflect cookie requirement. - Add 2 new tests: cookie loading from config, Referer/UA header verification. - Update docs: README, install guide, troubleshooting, SKILL.md, CHANGELOG.
This commit is contained in:
+1
-1
@@ -69,7 +69,7 @@ Update Agent Reach: https://raw.githubusercontent.com/Panniantong/agent-reach/ma
|
||||
| 💬 **WeChat Articles** | Search + Read | Zero config | Search + read WeChat Official Account articles (full Markdown) ([wechat-article-for-ai](https://github.com/Panniantong/wechat-article-for-ai) + [miku_ai](https://github.com/GobinFan/Miku_Spider)) |
|
||||
| 📰 **Weibo** | Trending · Search · Feeds · Comments | Zero config | Hot search, content/user/topic search, feeds, comments ([mcp-server-weibo](https://github.com/Panniantong/mcp-server-weibo)) |
|
||||
| 💻 **V2EX** | Hot topics · Node topics · Topic detail + replies · User profile | Zero config | Public JSON API, no auth required. Great for tech community content |
|
||||
| 📈 **Xueqiu (雪球)** | Stock quotes · Search · Hot posts · Hot stocks | Zero config | Public API with auto session cookies, no login required |
|
||||
| 📈 **Xueqiu (雪球)** | Stock quotes · Search · Hot posts · Hot stocks | Browser cookie | Tell your Agent "help me set up Xueqiu" |
|
||||
| 🎙️ **Xiaoyuzhou Podcast** | Transcription | Free API key | Podcast audio → full text transcript via Groq Whisper (free) |
|
||||
| 🔍 **Web Search** | Search | Auto-configured | Auto-configured during install, free, no API key ([Exa](https://exa.ai) via [mcporter](https://github.com/nicepkg/mcporter)) |
|
||||
| 📦 **GitHub** | Read · Search | Zero config | [gh CLI](https://cli.github.com) powered. Public repos work immediately. `gh auth login` unlocks Fork, Issue, PR |
|
||||
|
||||
+11
-2
@@ -112,13 +112,13 @@ Some channels need credentials only the user can provide. Based on the doctor ou
|
||||
|
||||
> 🍪 **Cookie 导入(所有需要登录的平台通用):**
|
||||
>
|
||||
> 所有需要 Cookie 的平台(Twitter、小红书等),**优先使用 Cookie-Editor 导入**,这是最简单最可靠的方式:
|
||||
> 所有需要 Cookie 的平台(Twitter、小红书、雪球等),**优先使用 Cookie-Editor 导入**,这是最简单最可靠的方式:
|
||||
> 1. 用户在自己的浏览器上登录对应平台
|
||||
> 2. 安装 [Cookie-Editor](https://chromewebstore.google.com/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm) Chrome 插件
|
||||
> 3. 点击插件 → Export → Header String
|
||||
> 4. 把导出的字符串发给 Agent
|
||||
>
|
||||
> **本地电脑用户**也可以用 `agent-reach configure --from-browser chrome` 一键自动提取(支持 Twitter + 小红书)。
|
||||
> **本地电脑用户**也可以用 `agent-reach configure --from-browser chrome` 一键自动提取(支持 Twitter + 小红书 + 雪球)。
|
||||
|
||||
**Twitter search & posting:**
|
||||
> "To unlock Twitter search, I need your Twitter cookies. Install the Cookie-Editor Chrome extension, go to x.com/twitter.com, click the extension → Export → Header String, and paste it to me."
|
||||
@@ -185,6 +185,15 @@ mcporter config add weibo --command 'mcp-server-weibo'
|
||||
|
||||
> 无需登录、无需 Cookie、无需代理。海外服务器也可以直接访问。
|
||||
|
||||
**雪球 / Xueqiu (股票行情 + 热门帖子):**
|
||||
> "雪球需要登录后的 Cookie。请先在 Chrome 里登录 xueqiu.com,然后运行:"
|
||||
|
||||
```bash
|
||||
agent-reach configure --from-browser chrome
|
||||
```
|
||||
|
||||
> Cookie 会随其他平台一起自动提取。
|
||||
|
||||
**小宇宙播客 / Xiaoyuzhou Podcast (Groq Whisper):**
|
||||
> "小宇宙播客转文字已默认安装,只需要一个免费的 Groq API Key。"
|
||||
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
# 常见问题排查
|
||||
|
||||
## 雪球 / Xueqiu: API 返回 400
|
||||
|
||||
**症状:** `agent-reach doctor` 显示雪球 ⚠️,报 `HTTP Error 400`
|
||||
|
||||
**原因:** 雪球 API 需要登录 Cookie,无法通过匿名访问获取。
|
||||
|
||||
**解决方案:** 在 Chrome 里登录 xueqiu.com,然后运行:
|
||||
|
||||
```bash
|
||||
agent-reach configure --from-browser chrome
|
||||
```
|
||||
|
||||
再次运行 `agent-reach doctor` 确认恢复 ✅。Cookie 过期后重新运行即可。
|
||||
|
||||
---
|
||||
|
||||
## Twitter/X: bird CLI 连接失败
|
||||
|
||||
**症状:** `bird search` 或其他命令返回错误
|
||||
|
||||
Reference in New Issue
Block a user