front/xhs-agent-desktop/engine/xhs_bridge/cookies_loader.py
zzh 5a26ae0048 feat: 小红书模块迁移、登录重构与 xhs-agent-desktop 桌面 Agent
- 新增小红书前端模块(启动服务、内容分析、爆款创作、发布记录、技能卡片、拟人设置、AI 助手)

- 新增 xhs-agent-desktop 独立桌面 Agent,对接 OMS 任务调度

- 登录页重构,整合微信登录与 OMS JWT 认证

- 订单、渠道、用户中心等页面与 API 增强

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 16:13:13 +08:00

33 lines
944 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""图片请求头构建(Cookie 由 extension_cookies 在失败时补充)。"""
from __future__ import annotations
def normalize_image_url(url: str) -> str:
url = (url or "").strip()
if url.startswith("//"):
return "https:" + url
return url
def image_request_headers(
*,
cookie_header: str | None = None,
accept: str = "image/avif,image/webp,image/apng,image/*,*/*;q=0.8",
) -> dict[str, str]:
from xhs_bridge.browser_profile import build_browser_headers, resolve_profile_for_request
from xhs_bridge.config import load_config
profile = resolve_profile_for_request(load_config())
return build_browser_headers(
profile=profile,
cookie_header=cookie_header or None,
with_cookie=False,
accept=accept,
extra={
"Sec-Fetch-Dest": "image",
"Sec-Fetch-Mode": "no-cors",
"Sec-Fetch-Site": "cross-site",
},
)