Skip to content

feat(nowcoder): add 牛客网 adapter with 16 commands#1036

Merged
jackwener merged 3 commits intojackwener:mainfrom
Cosmostima:feat/nowcoder-adapter
Apr 15, 2026
Merged

feat(nowcoder): add 牛客网 adapter with 16 commands#1036
jackwener merged 3 commits intojackwener:mainfrom
Cosmostima:feat/nowcoder-adapter

Conversation

@Cosmostima
Copy link
Copy Markdown
Contributor

Description

Add adapters for 牛客网 (Nowcoder), China's leading tech job-seeking and interview preparation community with millions of active users. Supports hot searches, trending posts, interview experiences, referral codes, salary reports, practice questions, and full-text search.

The adapter covers 16 commands across two strategy tiers:

  • 7 Public commands (Strategy.PUBLIC, no browser, ~1s) for publicly accessible data
  • 9 Cookie commands (browser required, ~7s) for authenticated content

Note: cli-manifest.json is not included as it is regenerated locally via npm run build and would pull in environment-specific paths.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Commands

Command Strategy Description
opencli nowcoder hot Public Hot search ranking
opencli nowcoder trending Public Trending posts
opencli nowcoder topics Public Hot discussion topics
opencli nowcoder recommend Public Recommended feed
opencli nowcoder creators Public Top content creators leaderboard
opencli nowcoder companies Public Hot companies for interview prep
opencli nowcoder jobs Public Career category listing
opencli nowcoder search <query> Cookie Full-text search (supports type: all/post/question/user/job)
opencli nowcoder suggest <query> Cookie Search suggestions
opencli nowcoder experience Cookie Interview experience posts
opencli nowcoder referral Cookie Internal referral posts
opencli nowcoder salary Cookie Salary disclosure posts
opencli nowcoder papers Cookie Interview question bank (filterable by company & job)
opencli nowcoder practice Cookie Categorized practice questions with progress tracking
opencli nowcoder notifications Cookie Unread message summary
opencli nowcoder detail <id> Cookie Post detail view (supports ID / UUID / URL)

Technical Notes

  • API Gateway: All endpoints go through gw-c.nowcoder.com/api/sparta/ (Spring Boot backend)
  • Auth: Public APIs require no credentials and use direct fetch pipeline steps. Cookie-tier APIs navigate to www.nowcoder.com first, then call the gateway with credentials: 'include' inside evaluate to send session cookies.
  • Search API: POST-based at /api/sparta/pc/search with JSON body, supports type filtering (all, post, question, user, job)
  • Tab Content API: Interview experience (tabId=818), referral (tabId=861), and salary (tabId=858) share the same endpoint /api/sparta/home/tab/content with different tab IDs
  • Data Linking: All list commands that return posts include an id field (UUID), enabling drill-down via opencli nowcoder detail <id>
  • HTML Stripping: Search and detail commands strip HTML tags from rich-text content for clean CLI output
  • Error handling: API failures throw Error with the server-side message (d.msg), surfaced by the pipeline evaluate step

Files

File Purpose
clis/nowcoder/hot.js Hot search ranking (Public)
clis/nowcoder/trending.js Trending posts (Public)
clis/nowcoder/topics.js Hot discussion topics (Public)
clis/nowcoder/recommend.js Recommended feed (Public)
clis/nowcoder/creators.js Top content creators leaderboard (Public)
clis/nowcoder/companies.js Hot companies for interview prep (Public)
clis/nowcoder/jobs.js Career category listing (Public)
clis/nowcoder/search.js Full-text search with type filtering (Cookie, POST API)
clis/nowcoder/suggest.js Search suggestions (Cookie, POST API)
clis/nowcoder/experience.js Interview experience posts (Cookie, tabId=818)
clis/nowcoder/referral.js Internal referral posts (Cookie, tabId=861)
clis/nowcoder/salary.js Salary disclosure posts (Cookie, tabId=858)
clis/nowcoder/papers.js Interview question bank by company & job (Cookie, POST API)
clis/nowcoder/practice.js Categorized practice questions with progress (Cookie)
clis/nowcoder/notifications.js Unread message summary (Cookie)
clis/nowcoder/detail.js Post detail view, supports ID / UUID / URL (Cookie)
docs/adapters/browser/nowcoder.md Adapter documentation page
docs/adapters/index.md Added row to Browser Adapters table
docs/.vitepress/config.mts Added sidebar entry

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Verification

  • npx tsc --noEmit passes
  • npm test passes (203 files, 1548 tests, 0 failures)
  • opencli validate passes (602 commands, 0 errors)
  • All 16 commands tested with real output via opencli nowcoder <cmd> -f json

Code Quality

  • Used positional args for the command's primary subject (query, id)
  • Normalized expected adapter failures to Error with server message
  • English column names throughout
  • cli() API format with proper args array syntax
  • All post-list commands include id for drill-down to detail
  • HTML tags stripped from rich-text content

Documentation

  • Added doc page under docs/adapters/browser/nowcoder.md
  • Updated docs/adapters/index.md table
  • Updated sidebar in docs/.vitepress/config.mts
  • Updated README.md / README.zh-CN.md when command discoverability changed

tima and others added 3 commits April 15, 2026 12:50
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>
@jackwener jackwener merged commit 44b4107 into jackwener:main Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants