From 98c9d93c9baa09edd6004adf9096cf1c8a45fd48 Mon Sep 17 00:00:00 2001 From: "Y. Zhang" Date: Mon, 16 Mar 2026 02:18:38 +0800 Subject: [PATCH] feat: add job URL support in cache and CSV export - index_cache.py: persist encryptJobId in cached entries so that job detail URLs can be constructed as: https://www.zhipin.com/job_detail/{encryptJobId}.html - search.py (export): add URL column to CSV output, making it easy to integrate with external tools (Notion, spreadsheets, etc.) This enables downstream workflows where users pipe exported data into databases or project management tools for tracking applications. --- boss_cli/commands/search.py | 5 ++++- boss_cli/index_cache.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/boss_cli/commands/search.py b/boss_cli/commands/search.py index 51160b1..9e6529d 100644 --- a/boss_cli/commands/search.py +++ b/boss_cli/commands/search.py @@ -327,10 +327,12 @@ def _collect(c: BossClient) -> list[dict]: else: # CSV buf = io.StringIO() - fieldnames = ["职位", "公司", "薪资", "经验", "学历", "城市", "地区", "技能", "securityId"] + fieldnames = ["职位", "公司", "薪资", "经验", "学历", "城市", "地区", "技能", "URL", "securityId"] writer = csv.DictWriter(buf, fieldnames=fieldnames, extrasaction="ignore") writer.writeheader() for job in all_jobs: + eid = job.get("encryptJobId", "") + url = f"https://www.zhipin.com/job_detail/{eid}.html" if eid else "" writer.writerow({ "职位": job.get("jobName", ""), "公司": job.get("brandName", ""), @@ -340,6 +342,7 @@ def _collect(c: BossClient) -> list[dict]: "城市": job.get("cityName", ""), "地区": job.get("areaDistrict", ""), "技能": ", ".join(job.get("skills", [])), + "URL": url, "securityId": job.get("securityId", ""), }) output_text = buf.getvalue() diff --git a/boss_cli/index_cache.py b/boss_cli/index_cache.py index ad6a1fb..6ef3eb3 100644 --- a/boss_cli/index_cache.py +++ b/boss_cli/index_cache.py @@ -35,6 +35,7 @@ def save_index(jobs: list[dict[str, Any]], source: str = "search") -> None: for job in jobs: entry = { "securityId": job.get("securityId", ""), + "encryptJobId": job.get("encryptJobId", ""), "jobName": job.get("jobName", ""), "brandName": job.get("brandName", ""), "salaryDesc": job.get("salaryDesc", ""),