Commit 701f021

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-09-15 13:38:58
fix(weibo): add mobile user-agent and cookies to avoid errors
1 parent e4da047
Changed files (1)
src
preview
src/preview/weibo.py
@@ -150,9 +150,9 @@ async def parse_weibo_info(post_id: str, data: dict | None = None, **kwargs) ->
     if not data:
         weibo_url = f"https://m.weibo.cn/detail/{post_id}"
         logger.info(f"Weibo link preview for {weibo_url}")
-        headers = {"referer": "https://m.weibo.cn"}
+        headers = {"referer": "https://m.weibo.cn", "cookie": await get_weibo_cookies()}
         try:
-            resp = await hx_req(weibo_url, headers=headers, rformat="text")
+            resp = await hx_req(weibo_url, headers=headers, mobile=True, rformat="text")
             if not resp.get("text"):
                 info["error_msg"] = f"Weibo webpage not found: {weibo_url}"
                 return info