9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
64 lines
2.8 KiB
JavaScript
64 lines
2.8 KiB
JavaScript
/**
|
|
* BOSS直聘 job detail — fetch full job posting details via browser cookie API.
|
|
*/
|
|
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import { requirePage, navigateTo, bossFetch, verbose } from './utils.js';
|
|
cli({
|
|
site: 'boss',
|
|
name: 'detail',
|
|
access: 'read',
|
|
description: 'BOSS直聘查看职位详情',
|
|
domain: 'www.zhipin.com',
|
|
strategy: Strategy.COOKIE,
|
|
navigateBefore: false,
|
|
browser: true,
|
|
args: [
|
|
{ name: 'security-id', positional: true, required: true, help: 'Security ID from search results (securityId field)' },
|
|
],
|
|
columns: [
|
|
'name', 'salary', 'experience', 'degree', 'city', 'district',
|
|
'description', 'skills', 'welfare',
|
|
'boss_name', 'boss_title', 'active_time',
|
|
'company', 'industry', 'scale', 'stage',
|
|
'address', 'url',
|
|
],
|
|
func: async (page, kwargs) => {
|
|
requirePage(page);
|
|
const securityId = kwargs['security-id'];
|
|
verbose('Fetching job detail...');
|
|
// Navigate to zhipin.com first to establish cookie context (referrer + cookies)
|
|
await navigateTo(page, 'https://www.zhipin.com/web/geek/job');
|
|
const targetUrl = `https://www.zhipin.com/wapi/zpgeek/job/detail.json?securityId=${encodeURIComponent(securityId)}`;
|
|
const data = await bossFetch(page, targetUrl);
|
|
const zpData = data.zpData || {};
|
|
const jobInfo = zpData.jobInfo || {};
|
|
const bossInfo = zpData.bossInfo || {};
|
|
const brandComInfo = zpData.brandComInfo || {};
|
|
if (!jobInfo.jobName) {
|
|
throw new Error('该职位信息不存在或已下架');
|
|
}
|
|
return [{
|
|
name: jobInfo.jobName || '',
|
|
salary: jobInfo.salaryDesc || '',
|
|
experience: jobInfo.experienceName || '',
|
|
degree: jobInfo.degreeName || '',
|
|
city: jobInfo.locationName || '',
|
|
district: [jobInfo.areaDistrict, jobInfo.businessDistrict].filter(Boolean).join('·'),
|
|
description: jobInfo.postDescription || '',
|
|
skills: (jobInfo.showSkills || []).join(', '),
|
|
welfare: (brandComInfo.labels || []).join(', '),
|
|
boss_name: bossInfo.name || '',
|
|
boss_title: bossInfo.title || '',
|
|
active_time: bossInfo.activeTimeDesc || '',
|
|
company: brandComInfo.brandName || bossInfo.brandName || '',
|
|
industry: brandComInfo.industryName || '',
|
|
scale: brandComInfo.scaleName || '',
|
|
stage: brandComInfo.stageName || '',
|
|
address: jobInfo.address || '',
|
|
url: jobInfo.encryptId
|
|
? 'https://www.zhipin.com/job_detail/' + jobInfo.encryptId + '.html'
|
|
: '',
|
|
}];
|
|
},
|
|
});
|