PC端
This commit is contained in:
+10
-6
@@ -6,8 +6,6 @@ binaries = []
|
||||
hiddenimports = []
|
||||
tmp_ret = collect_all('uvicorn')
|
||||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
|
||||
tmp_ret = collect_all('webview')
|
||||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
|
||||
|
||||
|
||||
a = Analysis(
|
||||
@@ -28,16 +26,13 @@ pyz = PYZ(a.pure)
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='Boss直聘AI投递',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
@@ -45,3 +40,12 @@ exe = EXE(
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name='Boss直聘AI投递',
|
||||
)
|
||||
|
||||
+9
-10
@@ -1,24 +1,23 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
REM ============================================================
|
||||
REM 打包客户端桌面版为单个 exe
|
||||
REM 产物:dist\Boss直聘AI投递.exe
|
||||
REM 使用:把 exe 复制到项目根目录(与 client 目录同级)双击运行,
|
||||
REM client\.env 等配置照常生效。
|
||||
REM 打包客户端桌面版(PySide6 + QtWebEngine,Win10/11 通用,零系统依赖)
|
||||
REM 产物:dist\Boss直聘AI投递\ 文件夹(内含 exe 及运行时)
|
||||
REM 使用:把整个文件夹拷到目标机器(或压缩成 zip 发送),
|
||||
REM 双击文件夹里的 Boss直聘AI投递.exe 运行。
|
||||
REM ============================================================
|
||||
|
||||
echo [1/2] 安装打包依赖...
|
||||
pip install pyinstaller pywebview --quiet
|
||||
pip install pyinstaller PySide6 --quiet
|
||||
if errorlevel 1 (
|
||||
echo 依赖安装失败,请检查 Python 环境
|
||||
pause & exit /b 1
|
||||
)
|
||||
|
||||
echo [2/2] PyInstaller 打包中(首次较慢,请耐心等待)...
|
||||
pyinstaller --noconfirm --clean --onefile --windowed ^
|
||||
echo [2/2] PyInstaller 打包中(Qt 体积大,首次较慢,请耐心等待)...
|
||||
pyinstaller --noconfirm --clean --onedir --windowed ^
|
||||
--name "Boss直聘AI投递" ^
|
||||
--collect-all uvicorn ^
|
||||
--collect-all webview ^
|
||||
--add-data "client\web\templates;client\web\templates" ^
|
||||
--add-data "client\web\static;client\web\static" ^
|
||||
client\desktop.py
|
||||
@@ -28,6 +27,6 @@ if errorlevel 1 (
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 打包完成:dist\Boss直聘AI投递.exe
|
||||
echo 请将该 exe 复制到项目根目录(与 client 文件夹同级)后双击运行。
|
||||
echo 打包完成:dist\Boss直聘AI投递\Boss直聘AI投递.exe
|
||||
echo 请将 dist\Boss直聘AI投递 整个文件夹拷贝到目标机器后双击 exe 运行。
|
||||
pause
|
||||
|
||||
+6
-6
@@ -1,8 +1,8 @@
|
||||
# ============ 客户端环境变量示例 ============
|
||||
# 复制本文件为 .env 并填写真实值:.env
|
||||
|
||||
# 云端服务端地址(部署后改成你的服务器地址)
|
||||
SERVER_URL=http://127.0.0.1:8000
|
||||
# 云端服务端地址(代码已内置生产地址,仅在需要覆盖时填写)
|
||||
#SERVER_URL=http://98.142.241.250:8000
|
||||
|
||||
# 本地控制面板端口
|
||||
WEB_PORT=8088
|
||||
@@ -17,9 +17,9 @@ BROWSER_MODE=chrome
|
||||
ADSPOWER_API_URL=http://local.adspower.net:50325
|
||||
ADSPOWER_USER_ID=
|
||||
|
||||
# AI 大模型(OpenAI 兼容接口)
|
||||
AI_BASE_URL=https://api.deepseek.com
|
||||
AI_MODEL=deepseek-chat
|
||||
AI_API_KEY=
|
||||
# AI 大模型(OpenAI 兼容接口,代码已内置生产配置,仅在需要覆盖时填写)
|
||||
#AI_BASE_URL=https://api.siliconflow.cn/v1
|
||||
#AI_MODEL=deepseek-ai/DeepSeek-V4-Flash
|
||||
#AI_API_KEY=
|
||||
# 低于该分数的职位自动跳过
|
||||
AI_MIN_SCORE=65
|
||||
|
||||
@@ -54,6 +54,7 @@ class JobCard:
|
||||
salary: str = ""
|
||||
jd_text: str = ""
|
||||
boss_online: bool = False
|
||||
headhunter: bool = False
|
||||
|
||||
|
||||
# 读取列表卡片(新版 DOM 结构)
|
||||
@@ -63,7 +64,8 @@ _CARDS_JS = """(() => [...document.querySelectorAll('.job-card-wrap')].map(el =>
|
||||
const t = s => { const n = el.querySelector(s); return n ? n.innerText.trim() : ''; };
|
||||
return {job_id: m ? m[1] : '', title: t('.job-name'), company: t('.boss-name'),
|
||||
location: t('.company-location'), tags: t('.tag-list'),
|
||||
online: !!el.querySelector('.boss-online-icon')};
|
||||
online: !!el.querySelector('.boss-online-icon'),
|
||||
hunter: [...el.querySelectorAll('span,i,em')].some(n => (n.innerText || '').trim() === '猎头')};
|
||||
}))()"""
|
||||
|
||||
# JD 正文(详情页,明文)
|
||||
@@ -165,7 +167,8 @@ class Applicant:
|
||||
def start(self, keywords: list[str], city_code: str,
|
||||
salary_min: int | None, salary_max: int | None,
|
||||
min_score: int, delay_range: tuple[int, int],
|
||||
boss_online_only: bool = False, daily_limit: int = 0) -> None:
|
||||
boss_online_only: bool = False, daily_limit: int = 0,
|
||||
allow_headhunter: bool = False) -> None:
|
||||
if self.is_running:
|
||||
logger.warning("已有投递任务在运行")
|
||||
return
|
||||
@@ -184,6 +187,7 @@ class Applicant:
|
||||
self.stats = {"applied": 0, "skipped": 0, "current": "初始化..."}
|
||||
self.boss_online_only = boss_online_only
|
||||
self.daily_limit = daily_limit
|
||||
self.allow_headhunter = allow_headhunter
|
||||
self._daily_base = 0
|
||||
|
||||
self._thread = threading.Thread(
|
||||
@@ -306,6 +310,7 @@ class Applicant:
|
||||
for j in jobs:
|
||||
if j.get("encryptJobId"):
|
||||
self._salary_by_id[j["encryptJobId"]] = j.get("salaryDesc") or ""
|
||||
logger.debug(f"捕获分页响应:{len(jobs)} 个职位,薪资表累计 {len(self._salary_by_id)} 条")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -327,6 +332,7 @@ class Applicant:
|
||||
company=it.get("company", ""), location=it.get("location", ""),
|
||||
tags=it.get("tags", ""), salary=it.get("salary", ""),
|
||||
boss_online=bool(it.get("online")),
|
||||
headhunter=bool(it.get("hunter")),
|
||||
))
|
||||
return cards
|
||||
|
||||
@@ -347,6 +353,7 @@ class Applicant:
|
||||
while applied < max_per_keyword and not self._should_stop():
|
||||
cards = self._read_cards()
|
||||
new_cards = [c for c in cards if c.job_id not in processed]
|
||||
logger.debug(f"列表读取:共 {len(cards)} 张卡片,新增 {len(new_cards)} 张")
|
||||
if not new_cards:
|
||||
no_new += 1
|
||||
if no_new >= 2:
|
||||
@@ -377,6 +384,8 @@ class Applicant:
|
||||
pass
|
||||
|
||||
self.stats["current"] = f"评估:{card.company} - {card.title}"
|
||||
logger.debug(f"开始处理卡片:{card.company} - {card.title}"
|
||||
f" | 薪资={card.salary or '未知'} | Boss在线={card.boss_online}")
|
||||
|
||||
# 薪资范围过滤(薪资来自站点分页响应明文)
|
||||
if salary_min or salary_max:
|
||||
@@ -393,6 +402,11 @@ class Applicant:
|
||||
self._report_skip(card, "Boss不在线")
|
||||
return 0
|
||||
|
||||
# 猎头过滤:开关关闭时跳过带猎头标识的职位
|
||||
if not self.allow_headhunter and card.headhunter:
|
||||
self._report_skip(card, "猎头职位")
|
||||
return 0
|
||||
|
||||
# 每日上限:达到后结束整个任务
|
||||
if self.daily_limit and self._daily_base + self.stats["applied"] >= self.daily_limit:
|
||||
logger.info(f"已达当日投递上限({self.daily_limit}),任务结束")
|
||||
@@ -431,6 +445,7 @@ class Applicant:
|
||||
jd = s.eval_js(_JD_JS) or ""
|
||||
finally:
|
||||
s.close()
|
||||
logger.debug(f"JD 抓取完成({len(jd.strip())} 字):{card.title}")
|
||||
return jd.strip() or f"{card.title} {card.company}"
|
||||
except Exception:
|
||||
return f"{card.title} {card.company}"
|
||||
@@ -450,6 +465,7 @@ class Applicant:
|
||||
logger.warning(f"未能在列表中选中卡片:{card.title}")
|
||||
return False
|
||||
p = json.loads(pos)
|
||||
logger.debug(f"选中卡片点击坐标:({p['x']}, {p['y']})")
|
||||
self._sess.human_click(p["x"], p["y"])
|
||||
time.sleep(1.5)
|
||||
|
||||
@@ -464,6 +480,7 @@ class Applicant:
|
||||
logger.warning(f"右侧面板无立即沟通按钮:{card.title}")
|
||||
return False
|
||||
p = json.loads(xy)
|
||||
logger.debug(f"立即沟通点击坐标:({p['x']}, {p['y']})")
|
||||
self._sess.human_click(p["x"], p["y"])
|
||||
|
||||
# 3. 等待"已向BOSS发送消息"弹窗,点"留在此页"
|
||||
|
||||
+6
-6
@@ -6,9 +6,9 @@ from pydantic_settings import BaseSettings
|
||||
|
||||
class ClientSettings(BaseSettings):
|
||||
# -------------------------------------------------------
|
||||
# 云端服务端地址
|
||||
# 云端服务端地址(默认内置生产地址,.env 可覆盖)
|
||||
# -------------------------------------------------------
|
||||
SERVER_URL: str = "http://127.0.0.1:8000"
|
||||
SERVER_URL: str = "http://98.142.241.250:8000"
|
||||
|
||||
# -------------------------------------------------------
|
||||
# 本地 Web 控制面板
|
||||
@@ -34,11 +34,11 @@ class ClientSettings(BaseSettings):
|
||||
ADSPOWER_USER_ID: str = ""
|
||||
|
||||
# -------------------------------------------------------
|
||||
# AI 大模型(OpenAI 兼容接口)
|
||||
# AI 大模型(OpenAI 兼容接口,默认内置生产配置,.env 可覆盖)
|
||||
# -------------------------------------------------------
|
||||
AI_BASE_URL: str = "https://api.deepseek.com"
|
||||
AI_MODEL: str = "deepseek-chat"
|
||||
AI_API_KEY: str = "" # 建议通过环境变量 AI_API_KEY 注入
|
||||
AI_BASE_URL: str = "https://api.siliconflow.cn/v1"
|
||||
AI_MODEL: str = "deepseek-ai/DeepSeek-V4-Flash"
|
||||
AI_API_KEY: str = "sk-wptdswlffnkdorhomdgfifhxxbrsuklsloardmclwxjjehpa"
|
||||
AI_MIN_SCORE: int = 65
|
||||
|
||||
# -------------------------------------------------------
|
||||
|
||||
+74
-19
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
客户端桌面版入口(pywebview)
|
||||
客户端桌面版入口(PySide6 + QtWebEngine,内嵌 Chromium,Win10/11 零系统依赖)
|
||||
双击运行:后台启动本地面板服务,并用独立桌面窗口展示控制面板。
|
||||
- 开发调试:python -m client.desktop
|
||||
- 仍想用浏览器打开面板:python -m client.desktop --browser
|
||||
- 打包 exe:运行项目根目录 build_exe.bat(产物放项目根目录运行,.env 等相对路径照常生效)
|
||||
- 打包 exe:运行项目根目录 build_exe.bat(产物整个文件夹拷走,双击其中 exe 运行)
|
||||
"""
|
||||
import os
|
||||
import socket
|
||||
@@ -55,8 +55,59 @@ def _port_serving(url: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _silence_stdio() -> None:
|
||||
"""GUI 模式无控制台:标准库 logging(uvicorn)写 None 会异常,兑底重定向到空设备"""
|
||||
if sys.stdout is None:
|
||||
sys.stdout = open(os.devnull, "w", encoding="utf-8")
|
||||
if sys.stderr is None:
|
||||
sys.stderr = open(os.devnull, "w", encoding="utf-8")
|
||||
|
||||
|
||||
def _run_qt_window(url: str) -> bool:
|
||||
"""QtWebEngine 桌面窗口(内嵌 Chromium,不依赖 WebView2/系统浏览器)"""
|
||||
try:
|
||||
from PySide6.QtCore import QUrl, Qt
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from PySide6.QtWebEngineWidgets import QWebEngineView
|
||||
except Exception as e:
|
||||
logger.warning(f"Qt 组件不可用:{e}")
|
||||
return False
|
||||
try:
|
||||
QApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
|
||||
app = QApplication(sys.argv[:1])
|
||||
app.setApplicationName("Boss直聘 AI 智能投递")
|
||||
view = QWebEngineView()
|
||||
view.setWindowTitle("Boss直聘 AI 智能投递")
|
||||
view.resize(1080, 800)
|
||||
view.load(QUrl(url))
|
||||
view.show()
|
||||
app.exec()
|
||||
return True
|
||||
except Exception:
|
||||
logger.exception("Qt 窗口启动失败")
|
||||
return False
|
||||
|
||||
|
||||
def _browser_fallback(url: str, reason: str) -> None:
|
||||
"""桌面窗口不可用时降级为浏览器模式,服务保持常驻"""
|
||||
logger.warning(f"{reason},降级为浏览器模式:{url}")
|
||||
import ctypes
|
||||
ctypes.windll.user32.MessageBoxW(
|
||||
0,
|
||||
f"{reason}。\n已改用默认浏览器打开控制面板,功能完全一致。",
|
||||
"提示", 0x40,
|
||||
)
|
||||
webbrowser.open(url)
|
||||
try:
|
||||
while True:
|
||||
time.sleep(3600)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
|
||||
def main() -> None:
|
||||
setup_logger()
|
||||
_silence_stdio()
|
||||
|
||||
host = client_settings.WEB_HOST
|
||||
port = client_settings.WEB_PORT
|
||||
@@ -65,13 +116,16 @@ def main() -> None:
|
||||
if _port_serving(url):
|
||||
logger.info("检测到面板服务已在运行,直接打开桌面窗口")
|
||||
else:
|
||||
# 面板服务放到后台线程,主线程留给桌面窗口(webview 要求占用主线程)
|
||||
# 面板服务放到后台线程,主线程留给桌面窗口(Qt 事件循环要求占用主线程)
|
||||
from client.web.app import app
|
||||
threading.Thread(
|
||||
target=uvicorn.run,
|
||||
kwargs={"app": app, "host": host, "port": port, "log_level": "warning"},
|
||||
daemon=True,
|
||||
).start()
|
||||
|
||||
def _run_server():
|
||||
try:
|
||||
uvicorn.run(app, host=host, port=port, log_level="warning")
|
||||
except Exception:
|
||||
logger.exception("面板服务异常退出")
|
||||
|
||||
threading.Thread(target=_run_server, daemon=True).start()
|
||||
|
||||
if "--browser" in sys.argv:
|
||||
# 兼容旧习惯:浏览器打开面板,服务前台常驻
|
||||
@@ -89,23 +143,24 @@ def main() -> None:
|
||||
|
||||
if not _wait_port(port):
|
||||
logger.error("面板服务启动超时,请查看 client/logs/client.log")
|
||||
if sys.stdin is not None: # 仅控制台模式下可交互
|
||||
input("按回车退出...")
|
||||
else:
|
||||
import ctypes
|
||||
ctypes.windll.user32.MessageBoxW(
|
||||
0, "面板服务启动超时,请查看 client/logs/client.log", "启动失败", 0x10)
|
||||
sys.exit(1)
|
||||
|
||||
logger.success(f"桌面窗口已就绪(服务地址:{url})")
|
||||
|
||||
import webview
|
||||
window = webview.create_window(
|
||||
"Boss直聘 AI 智能投递",
|
||||
url,
|
||||
width=1080,
|
||||
height=800,
|
||||
min_size=(960, 680),
|
||||
background_color="#f0f4f8",
|
||||
)
|
||||
# gui 参数留空 = 自动选择系统最佳渲染(Win10/11 用 WebView2)
|
||||
webview.start(debug=False)
|
||||
if not _run_qt_window(url):
|
||||
_browser_fallback(url, "桌面窗口启动失败")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except Exception:
|
||||
# GUI 模式无控制台,崩溃时先落盘日志便于排查
|
||||
logger.exception("桌面客户端异常退出")
|
||||
raise
|
||||
|
||||
+30
-1
@@ -8,13 +8,14 @@ import threading
|
||||
import webbrowser
|
||||
import uvicorn
|
||||
from loguru import logger
|
||||
|
||||
from .config import client_settings
|
||||
from .fingerprint import get_machine_summary
|
||||
|
||||
|
||||
def setup_logger() -> None:
|
||||
logger.remove()
|
||||
# 桌面打包模式(--windowed)下 stderr 为 None,控制台日志降级为仅写文件
|
||||
if sys.stderr is not None:
|
||||
logger.add(
|
||||
sys.stderr,
|
||||
level="INFO",
|
||||
@@ -30,6 +31,34 @@ def setup_logger() -> None:
|
||||
retention="7 days",
|
||||
enqueue=True,
|
||||
)
|
||||
start_log_cleanup()
|
||||
|
||||
|
||||
def _cleanup_old_logs(days: int = 7) -> None:
|
||||
"""删除超过 days 天的日志文件(retention 只在轮转时触发,这里主动循环清理)"""
|
||||
import os
|
||||
import time as _time
|
||||
from pathlib import Path
|
||||
log_dir = Path("client/logs")
|
||||
if not log_dir.exists():
|
||||
return
|
||||
cutoff = _time.time() - days * 86400
|
||||
for f in log_dir.glob("*.log*"):
|
||||
try:
|
||||
if f.stat().st_mtime < cutoff:
|
||||
f.unlink(missing_ok=True)
|
||||
logger.info(f"清理过期日志:{f.name}")
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def start_log_cleanup(days: int = 7) -> None:
|
||||
"""启动时清一次,之后每天循环清理"""
|
||||
def _loop():
|
||||
while True:
|
||||
_cleanup_old_logs(days)
|
||||
threading.Event().wait(86400)
|
||||
threading.Thread(target=_loop, daemon=True).start()
|
||||
|
||||
|
||||
def open_browser_later(url: str, delay: float = 1.5) -> None:
|
||||
|
||||
@@ -9,4 +9,4 @@ pydantic>=2.7.0
|
||||
pydantic-settings>=2.3.0
|
||||
loguru>=0.7.2
|
||||
websocket-client>=1.7.0
|
||||
pywebview>=5.0
|
||||
PySide6>=6.6
|
||||
|
||||
+35
-19
@@ -3,6 +3,7 @@
|
||||
统一管理 token 持久化与请求头
|
||||
"""
|
||||
import os
|
||||
import time
|
||||
import requests
|
||||
from loguru import logger
|
||||
|
||||
@@ -49,12 +50,27 @@ class ServerAPI:
|
||||
def _headers(self) -> dict:
|
||||
return {"Authorization": f"Bearer {self.token}"} if self.token else {}
|
||||
|
||||
def _req(self, method: str, url: str, **kwargs) -> requests.Response:
|
||||
"""云端请求统一入口:网络层异常重试 5 次、每次间隔 1 秒,仍失败才抛出。
|
||||
仅重试连接类异常(RequestException 发生在请求阶段);
|
||||
HTTP 状态码错误由调用方 raise_for_status 抛出,不重试。"""
|
||||
last: Exception | None = None
|
||||
for i in range(5):
|
||||
try:
|
||||
return requests.request(method, url, **kwargs)
|
||||
except requests.RequestException as e:
|
||||
last = e
|
||||
logger.warning(f"云端请求失败({i + 1}/5),1 秒后重试:"
|
||||
f"{method.upper()} {url}:{e}")
|
||||
time.sleep(1)
|
||||
raise last
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 认证(账号密码体系)
|
||||
# ------------------------------------------------------------------
|
||||
def register(self, username: str, password: str, nickname: str | None = None) -> dict:
|
||||
"""注册新账号,返回并保存 token"""
|
||||
resp = requests.post(
|
||||
resp = self._req("post",
|
||||
f"{self.base_url}/api/auth/register",
|
||||
json={"username": username, "password": password, "nickname": nickname},
|
||||
timeout=15,
|
||||
@@ -64,7 +80,7 @@ class ServerAPI:
|
||||
|
||||
def login(self, username: str, password: str) -> dict:
|
||||
"""账号密码登录,返回并保存 token"""
|
||||
resp = requests.post(
|
||||
resp = self._req("post",
|
||||
f"{self.base_url}/api/auth/login",
|
||||
json={
|
||||
"username": username,
|
||||
@@ -97,7 +113,7 @@ class ServerAPI:
|
||||
pass
|
||||
|
||||
def get_me(self) -> dict:
|
||||
resp = requests.get(f"{self.base_url}/api/auth/me", headers=self._headers(), timeout=15)
|
||||
resp = self._req("get", f"{self.base_url}/api/auth/me", headers=self._headers(), timeout=15)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
@@ -106,7 +122,7 @@ class ServerAPI:
|
||||
if not self.token:
|
||||
return False
|
||||
try:
|
||||
resp = requests.post(
|
||||
resp = self._req("post",
|
||||
f"{self.base_url}/api/auth/heartbeat",
|
||||
headers=self._headers(), timeout=10,
|
||||
)
|
||||
@@ -119,7 +135,7 @@ class ServerAPI:
|
||||
payload = {"login_status": status}
|
||||
if boss_account:
|
||||
payload["boss_account"] = boss_account
|
||||
resp = requests.put(
|
||||
resp = self._req("put",
|
||||
f"{self.base_url}/api/auth/login-status",
|
||||
json=payload, headers=self._headers(), timeout=15,
|
||||
)
|
||||
@@ -131,7 +147,7 @@ class ServerAPI:
|
||||
# ------------------------------------------------------------------
|
||||
def upload_resumes(self, resumes: list[dict]) -> list[dict]:
|
||||
"""批量上传简历"""
|
||||
resp = requests.post(
|
||||
resp = self._req("post",
|
||||
f"{self.base_url}/api/resumes/batch",
|
||||
json={"resumes": resumes}, headers=self._headers(), timeout=30,
|
||||
)
|
||||
@@ -139,19 +155,19 @@ class ServerAPI:
|
||||
return resp.json()
|
||||
|
||||
def list_resumes(self) -> list[dict]:
|
||||
resp = requests.get(f"{self.base_url}/api/resumes", headers=self._headers(), timeout=15)
|
||||
resp = self._req("get", f"{self.base_url}/api/resumes", headers=self._headers(), timeout=15)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
def get_primary_resume(self) -> dict | None:
|
||||
resp = requests.get(f"{self.base_url}/api/resumes/primary", headers=self._headers(), timeout=15)
|
||||
resp = self._req("get", f"{self.base_url}/api/resumes/primary", headers=self._headers(), timeout=15)
|
||||
if resp.status_code == 404:
|
||||
return None
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
def set_primary_resume(self, resume_id: int) -> dict:
|
||||
resp = requests.post(
|
||||
resp = self._req("post",
|
||||
f"{self.base_url}/api/resumes/{resume_id}/set-primary",
|
||||
headers=self._headers(), timeout=15,
|
||||
)
|
||||
@@ -160,7 +176,7 @@ class ServerAPI:
|
||||
|
||||
def update_resume(self, resume_id: int, data: dict) -> dict:
|
||||
"""编辑简历(标题/求职意向/正文)"""
|
||||
resp = requests.put(
|
||||
resp = self._req("put",
|
||||
f"{self.base_url}/api/resumes/{resume_id}",
|
||||
json=data, headers=self._headers(), timeout=15,
|
||||
)
|
||||
@@ -168,7 +184,7 @@ class ServerAPI:
|
||||
return resp.json()
|
||||
|
||||
def delete_resume(self, resume_id: int) -> dict:
|
||||
resp = requests.delete(
|
||||
resp = self._req("delete",
|
||||
f"{self.base_url}/api/resumes/{resume_id}",
|
||||
headers=self._headers(), timeout=15,
|
||||
)
|
||||
@@ -180,7 +196,7 @@ class ServerAPI:
|
||||
# ------------------------------------------------------------------
|
||||
def start_session(self, keywords: str, city_code: str,
|
||||
salary_min: int | None, salary_max: int | None) -> dict:
|
||||
resp = requests.post(
|
||||
resp = self._req("post",
|
||||
f"{self.base_url}/api/sessions/start",
|
||||
json={
|
||||
"keywords": keywords,
|
||||
@@ -194,7 +210,7 @@ class ServerAPI:
|
||||
return resp.json()
|
||||
|
||||
def stop_session(self, session_id: int) -> dict:
|
||||
resp = requests.post(
|
||||
resp = self._req("post",
|
||||
f"{self.base_url}/api/sessions/{session_id}/stop",
|
||||
headers=self._headers(), timeout=15,
|
||||
)
|
||||
@@ -202,7 +218,7 @@ class ServerAPI:
|
||||
return resp.json()
|
||||
|
||||
def update_session_stats(self, session_id: int, applied_delta: int, skipped_delta: int) -> dict:
|
||||
resp = requests.post(
|
||||
resp = self._req("post",
|
||||
f"{self.base_url}/api/sessions/{session_id}/stats",
|
||||
json={"applied_delta": applied_delta, "skipped_delta": skipped_delta},
|
||||
headers=self._headers(), timeout=15,
|
||||
@@ -215,7 +231,7 @@ class ServerAPI:
|
||||
# ------------------------------------------------------------------
|
||||
def report_application(self, session_id: int | None, data: dict) -> dict:
|
||||
params = {"session_id": session_id} if session_id else {}
|
||||
resp = requests.post(
|
||||
resp = self._req("post",
|
||||
f"{self.base_url}/api/jobs/report",
|
||||
json=data, params=params, headers=self._headers(), timeout=15,
|
||||
)
|
||||
@@ -223,7 +239,7 @@ class ServerAPI:
|
||||
return resp.json()
|
||||
|
||||
def check_applied(self, job_id: str) -> bool:
|
||||
resp = requests.get(
|
||||
resp = self._req("get",
|
||||
f"{self.base_url}/api/jobs/check/{job_id}",
|
||||
headers=self._headers(), timeout=15,
|
||||
)
|
||||
@@ -231,13 +247,13 @@ class ServerAPI:
|
||||
return resp.json().get("applied", False)
|
||||
|
||||
def get_stats(self) -> dict:
|
||||
resp = requests.get(f"{self.base_url}/api/jobs/stats", headers=self._headers(), timeout=15)
|
||||
resp = self._req("get", f"{self.base_url}/api/jobs/stats", headers=self._headers(), timeout=15)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
def today_applied_count(self) -> int:
|
||||
"""当天(北京时间)实际投递数量"""
|
||||
resp = requests.get(f"{self.base_url}/api/jobs/today-count", headers=self._headers(), timeout=15)
|
||||
resp = self._req("get", f"{self.base_url}/api/jobs/today-count", headers=self._headers(), timeout=15)
|
||||
resp.raise_for_status()
|
||||
return int(resp.json().get("count", 0))
|
||||
|
||||
@@ -245,7 +261,7 @@ class ServerAPI:
|
||||
params = {"limit": limit}
|
||||
if apply_type:
|
||||
params["apply_type"] = apply_type
|
||||
resp = requests.get(
|
||||
resp = self._req("get",
|
||||
f"{self.base_url}/api/jobs/history",
|
||||
params=params, headers=self._headers(), timeout=15,
|
||||
)
|
||||
|
||||
@@ -113,6 +113,7 @@ class StartApplyReq(BaseModel):
|
||||
delay_max: int = 8
|
||||
boss_online_only: bool = False
|
||||
daily_limit: int = 0
|
||||
allow_headhunter: bool = False
|
||||
|
||||
|
||||
class ResumeUpdateReq(BaseModel):
|
||||
@@ -391,6 +392,7 @@ def start_apply(req: StartApplyReq):
|
||||
delay_range=(req.delay_min, req.delay_max),
|
||||
boss_online_only=req.boss_online_only,
|
||||
daily_limit=req.daily_limit,
|
||||
allow_headhunter=req.allow_headhunter,
|
||||
)
|
||||
return {"ok": True, "session_id": applicant.session_id}
|
||||
|
||||
|
||||
@@ -377,6 +377,7 @@ $('btnStartApply').addEventListener('click', async () => {
|
||||
salary_max: parseInt($('salaryMax').value) || null,
|
||||
min_score: parseInt($('minScore').value) || 65,
|
||||
boss_online_only: $('bossOnlineOnly').checked,
|
||||
allow_headhunter: $('allowHeadhunter').checked,
|
||||
daily_limit: parseInt($('dailyLimit').value) || 0,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Boss直聘 AI 智能投递</title>
|
||||
<link rel="stylesheet" href="/static/style.css?v=2">
|
||||
<link rel="stylesheet" href="/static/style.css?v=3">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
@@ -123,6 +123,9 @@
|
||||
<label style="display:flex;align-items:center;gap:6px;margin:0;cursor:pointer;">
|
||||
<input type="checkbox" id="bossOnlineOnly" style="width:auto;"> 只投递 Boss 在线的
|
||||
</label>
|
||||
<label style="display:flex; align-items:center; gap:6px; margin-top:8px;">
|
||||
<input type="checkbox" id="allowHeadhunter" style="width:auto;"> 考虑猎头职位
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="action-buttons">
|
||||
@@ -176,6 +179,6 @@
|
||||
<!-- Toast 提示 -->
|
||||
<div class="toast" id="toast"></div>
|
||||
|
||||
<script src="/static/app.js?v=2"></script>
|
||||
<script src="/static/app.js?v=3"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user