feat: add Chinese academic & policy database adapters#243
feat: add Chinese academic & policy database adapters#243Muuuun wants to merge 4 commits intojackwener:mainfrom
Conversation
Add 7 new adapters for Chinese academic and government databases: Academic: - baidu-scholar/search: 百度学术论文搜索 (cookie + DOM extraction) - wanfang/search: 万方数据论文搜索 (cookie + DOM extraction) - google-scholar/search: Google Scholar 学术搜索 (cookie + DOM extraction) Policy & Law: - gov-law/search: 国家法律法规数据库搜索 (cookie + Vue Router injection) - gov-law/recent: 最新法律法规 (cookie + Vue Router) - gov-policy/search: 中国政府网政策文件搜索 (cookie + DOM extraction) - gov-policy/recent: 国务院最新政策文件 (cookie + DOM extraction) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Astro-Han
left a comment
There was a problem hiding this comment.
Great coverage of academic and government data sources — the gov-law Vue Router technique is clever. A few things I noticed:
gov-policy/recent.ts — missing navigateBefore: false
The other 6 adapters all set navigateBefore: false, but this one doesn't. With Strategy.COOKIE + domain, the framework will auto-navigate to www.gov.cn before func runs, then func navigates again to the target URL — double navigation adding 2-4s overhead.
Strategy — COOKIE vs PUBLIC
These sites all serve public data without requiring login. Strategy.COOKIE forces users to go through the browser extension flow, while Strategy.PUBLIC (with browser: true if DOM extraction is needed) would be lighter. See google/search.ts for a similar pattern.
baidu-scholar/search.ts:43 — duplicate condition
if (t.startsWith('《') || t.startsWith('《'))Both sides are the same character (U+300A). The second branch is always redundant.
gov-law — Vue Router fallback
app.__vue_app__.config.globalProperties.$router is a Vue 3 internal — if the site upgrades or restructures, this silently returns nothing. A null guard with a descriptive CliError would help users understand why the command stopped working.
Tests & docs
No E2E tests or documentation updates (README, docs/adapters/, SKILL.md, vitepress sidebar). Per TESTING.md, browser commands should have entries in browser-public.test.ts (or browser-auth.test.ts).
- Change Strategy.COOKIE to Strategy.PUBLIC + browser:true for all adapters (these sites serve public data without login) - Add navigateBefore:false to gov-policy/recent.ts (was missing, causing double navigation) - Fix duplicate condition in baidu-scholar/search.ts (both sides of || were identical U+300A) - Add Vue Router null guards with CliError to gov-law/search.ts and gov-law/recent.ts for graceful failure if site restructures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add 7 browser-public E2E tests covering all new adapters: - baidu-scholar/search - google-scholar/search - wanfang/search - gov-law/recent, gov-law/search - gov-policy/recent, gov-policy/search Tests use tryBrowserCommand + expectDataOrSkip pattern (warn+pass on geo-blocking/bot-detection, per TESTING.md conventions). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Astro-Han
left a comment
There was a problem hiding this comment.
Thanks for addressing the feedback! Strategy, tests, duplicate condition, and Vue Router guard all look good now. LGTM from my side.
Minor remaining nits (non-blocking):
gov-law/recent.tsandsearch.tsshare ~15 lines of identical DOM extraction — could be a shared helper- The
'no_router'return fromevaluateis not consumed; thelocation.hrefcheck works but is indirect - No doc updates (README,
docs/adapters/, SKILL.md) — deferring to maintainer on whether that's needed in this PR
- Extract navigateViaVueRouter() and extractLawResults() into gov-law/shared.ts — eliminates ~15 lines of duplication - CliError is now thrown directly in shared helper (no unconsumed 'no_router' return value) - search.ts and recent.ts simplified to ~20 lines each Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
baidu-scholar/search,wanfang/search,google-scholar/searchgov-law/search,gov-law/recent,gov-policy/search,gov-policy/recentDetails
baidu-scholar search <query>wanfang search <query>google-scholar search <query>gov-law search <query>gov-law recentgov-policy search <query>gov-policy recentNotable techniques
Vue Router.push()withsearchWordquery param, after injecting the search term into the input via native value setter to trigger Vue's reactivity.sousuo.www.gov.cn/sousuo/search.shtml(not the obvioussousuo.gov.cnwhich doesn't resolve).span.title,span.authors,span.essay-typeremain stable selectors.Test plan
npx tsc --noEmit— type check passednpx vitest run src/— 306 tests passedopencli validate— 86 CLI definitions validated, 0 errors🤖 Generated with Claude Code