- 新增小红书前端模块(启动服务、内容分析、爆款创作、发布记录、技能卡片、拟人设置、AI 助手) - 新增 xhs-agent-desktop 独立桌面 Agent,对接 OMS 任务调度 - 登录页重构,整合微信登录与 OMS JWT 认证 - 订单、渠道、用户中心等页面与 API 增强 Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
944 B
Python
33 lines
944 B
Python
"""图片请求头构建(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",
|
||
},
|
||
)
|