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
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
# ⚠️ DEPRECATED — 2026-03-21
|
|
# 此文件是内部手工复制文件,已废弃,不再由任何 facade 引用。
|
|
# 请改用 spiderJobs.platforms.* 或 crawler_core 中的对应模块。
|
|
# 将在下一里程碑中删除。
|
|
#
|
|
"""
|
|
前程无忧 (51Job) 签名算法
|
|
复制自 spiderJobs/platforms/job51/sign.py — import 改为本地引用
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hmac
|
|
import hashlib
|
|
import time
|
|
import random
|
|
from urllib.parse import quote
|
|
|
|
|
|
SIGN_KEY = "abfc8f9dcf8c3f3d8aa294ac5f2cf2cc7767e5592590f39c3f503271dd68562b"
|
|
|
|
|
|
class Job51Sign:
|
|
def __init__(self, *, sign_key: str = SIGN_KEY):
|
|
self.sign_key = sign_key
|
|
|
|
@staticmethod
|
|
def generate_uuid() -> str:
|
|
ts = str(int(time.time() * 1000))
|
|
rand = str(random.randint(1000000000, 9999999999))
|
|
return ts + rand
|
|
|
|
def build_sign_path(
|
|
self,
|
|
endpoint: str,
|
|
method: str = "GET",
|
|
params: dict | None = None,
|
|
body: dict | None = None,
|
|
) -> tuple[str, str]:
|
|
import json
|
|
|
|
ts = int(time.time())
|
|
path = f"/{endpoint}?api_key=51job×tamp={ts}"
|
|
|
|
if method.upper() == "GET" and params:
|
|
query_parts = []
|
|
for k, v in params.items():
|
|
query_parts.append(f"{quote(str(k), safe='')}={quote(str(v), safe='')}")
|
|
if query_parts:
|
|
path += "&" + "&".join(query_parts)
|
|
|
|
message = path
|
|
if method.upper() == "POST" and body is not None:
|
|
message += json.dumps(body, ensure_ascii=False, separators=(",", ":"))
|
|
|
|
sign_hex = hmac.new(
|
|
self.sign_key.encode("utf-8"),
|
|
message.encode("utf-8"),
|
|
hashlib.sha256,
|
|
).hexdigest()
|
|
|
|
return path, sign_hex
|