Plan 01 - facade migration (ARCH-06/07):
- boss.py: import from spiderJobs.platforms.boss.{api,client,sign}
- qcwy.py: import from spiderJobs.platforms.job51.{api,client}
- zhilian.py: import from spiderJobs.platforms.zhilian.{api,client,sign}
- All 3 Service classes: +4 async_* methods via asyncio.to_thread()
Plan 02 - deprecation + cleanup (ARCH-08):
- 11 private copy files (_base, _http_client, _boss/job51/zhilian *): DEPRECATED header
- jobs_spider/ directory: fully deleted (user request)
Full regression: 106 passed in 0.61s
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
# ⚠️ DEPRECATED — 2026-03-21
|
|
# 此文件是内部手工复制文件,已废弃,不再由任何 facade 引用。
|
|
# 请改用 spiderJobs.platforms.* 或 crawler_core 中的对应模块。
|
|
# 将在下一里程碑中删除。
|
|
#
|
|
"""
|
|
智联招聘签名算法
|
|
复制自 spiderJobs/platforms/zhilian/sign.py — import 改为本地引用
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import math
|
|
import random
|
|
from typing import Optional
|
|
|
|
|
|
class ZhilianSign:
|
|
def __init__(
|
|
self, *, at: str = "", rt: str = "",
|
|
device_id: Optional[str] = None, version: str = "4.1.259",
|
|
channel: str = "wxxiaochengxu", platform: str = "12",
|
|
):
|
|
self.at = at
|
|
self.rt = rt
|
|
self.device_id = device_id or self.generate_uuid()
|
|
self.version = version
|
|
self.channel = channel
|
|
self.platform = platform
|
|
|
|
@staticmethod
|
|
def generate_uuid() -> str:
|
|
chars = "0123456789ABCDEF"
|
|
uuid = [""] * 36
|
|
for i in range(36):
|
|
uuid[i] = chars[math.floor(16 * random.random())]
|
|
uuid[14] = "4"
|
|
uuid[19] = chars[(int(uuid[19], 16) & 0x3) | 0x8]
|
|
uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-"
|
|
return "".join(uuid)
|
|
|
|
def sign_headers(self, page_code: str = "0") -> dict:
|
|
return {
|
|
"x-zp-at": self.at,
|
|
"x-zp-rt": self.rt,
|
|
"x-zp-action-id": self.generate_uuid(),
|
|
"x-zp-page-code": page_code,
|
|
"x-zp-version": self.version,
|
|
"x-zp-channel": self.channel,
|
|
"x-zp-platform": self.platform,
|
|
"x-zp-device-id": self.device_id,
|
|
"x-zp-business-system": "73",
|
|
}
|
|
|
|
def sign_params(self) -> dict:
|
|
return {
|
|
"at": self.at,
|
|
"rt": self.rt,
|
|
"channel": self.channel,
|
|
"platform": self.platform,
|
|
"version": self.version,
|
|
"d": self.device_id,
|
|
}
|