Commit d496935

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-10-03 12:35:54
fix(weibo): use proxy for weibo requests
1 parent ca6e627
Changed files (1)
src
preview
src/preview/weibo.py
@@ -152,7 +152,7 @@ async def parse_weibo_info(post_id: str, data: dict | None = None, **kwargs) ->
         logger.info(f"Weibo link preview for {weibo_url}")
         headers = {"referer": "https://m.weibo.cn", "cookie": await get_weibo_cookies()}
         try:
-            resp = await hx_req(weibo_url, headers=headers, mobile=True, rformat="text")
+            resp = await hx_req(weibo_url, headers=headers, proxy=PROXY.WEIBO, mobile=True, rformat="text")
             if not resp.get("text"):
                 info["error_msg"] = f"Weibo webpage not found: {weibo_url}"
                 return info
@@ -241,7 +241,7 @@ async def weibo_vid_to_postid(post_id: str) -> str:
     url = f"https://video.weibo.com/show?fid={post_id.removeprefix('weibovideo')}"
     api_url = f"{API.TIKHUB_WEIBO_VIDEO}{quote_plus(url)}"
     headers = {"authorization": f"Bearer {TOKEN.TIKHUB}", "accept": "application/json"}
-    resp = await hx_req(api_url, headers=headers, check_kv={"data.msg": "succ"}, check_keys=["data.data.Component_Play_Playinfo.mid"])
+    resp = await hx_req(api_url, headers=headers, proxy=PROXY.WEIBO, check_kv={"data.msg": "succ"}, check_keys=["data.data.Component_Play_Playinfo.mid"])
     return str(glom(resp, "data.data.Component_Play_Playinfo.mid", default=""))
 
 
@@ -279,7 +279,7 @@ async def parse_weibo_comments(post_id: str) -> list[str]:
         "max_id": 0,
     }
     api = "https://weibo.com/ajax/statuses/buildComments"
-    resp = await hx_req(api, headers=headers, params=params, check_kv={"ok": 1}, max_retry=1)
+    resp = await hx_req(api, headers=headers, params=params, proxy=PROXY.WEIBO, check_kv={"ok": 1}, max_retry=1)
     if resp.get("hx_error"):
         logger.error(f"Weibo Comments API failed: {resp}")
         return []