mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
44b4107f36
* feat(nowcoder): add 牛客网 adapter with 16 commands Add adapters for Nowcoder (牛客网), China's leading tech job-seeking and interview preparation community. - 7 Public commands: hot, trending, topics, recommend, creators, companies, jobs - 9 Cookie commands: search, suggest, experience, referral, salary, papers, practice, notifications, detail - All post-list commands include id field for drill-down to detail - Documentation: adapter page, index table, sidebar entry Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(nowcoder): register adapter and document usage --------- Co-authored-by: tima <tima@cosmos-macmini.local> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: jackwener <jakevingoo@gmail.com>
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
import { cli } from '@jackwener/opencli/registry';
|
|
|
|
cli({
|
|
site: 'nowcoder',
|
|
name: 'papers',
|
|
description: 'Interview question bank by company and job',
|
|
domain: 'www.nowcoder.com',
|
|
args: [
|
|
{ name: 'job', type: 'str', default: '11002', help: 'Job ID (11002=Java, 11003=C++, 11200=Backend, 11203=QA, 11201=Frontend)' },
|
|
{ name: 'company', type: 'str', default: '', help: 'Company ID (e.g. 139=Baidu, 138=Tencent, 239=Huawei)' },
|
|
{ name: 'limit', type: 'int', default: 10, help: 'Number of items' },
|
|
],
|
|
columns: ['rank', 'title', 'company', 'practitioners'],
|
|
pipeline: [
|
|
{ navigate: 'https://www.nowcoder.com' },
|
|
{ evaluate: `(async () => {
|
|
const jobId = parseInt(\${{ args.job | json }});
|
|
const companyId = \${{ args.company | json }};
|
|
const limit = \${{ args.limit }};
|
|
const body = {jobId, page: 1, pageSize: limit};
|
|
if (companyId) body.companyId = parseInt(companyId);
|
|
const r = await fetch('https://gw-c.nowcoder.com/api/sparta/company-question/get-paper-list', {
|
|
method: 'POST',
|
|
credentials: 'include',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify(body)
|
|
});
|
|
const d = await r.json();
|
|
if (!d.success) throw new Error(d.msg || 'API failed');
|
|
return (d.data?.records || []).map((p, i) => ({
|
|
rank: i + 1,
|
|
title: p.paperName || '',
|
|
company: p.companyTag?.name || '',
|
|
practitioners: p.practiceCnt || 0,
|
|
}));
|
|
})()
|
|
` },
|
|
{ limit: '${{ args.limit }}' },
|
|
],
|
|
});
|