Loading...
Loading...
Search CNKI (中国知网) for papers by keyword. Use when the user wants to find academic papers on a topic.
npx skill4agent add cookjohn/cnki-skills cnki-searchmcp__chrome-devtools__navigate_pagehttps://kns.cnki.net/kns8s/searchYOUR_KEYWORDSasync () => {
const query = "YOUR_KEYWORDS";
// Wait for search input (replaces wait_for)
await new Promise((r, j) => {
let n = 0;
const c = () => { if (document.querySelector('input.search-input')) r(); else if (++n > 30) j('timeout'); else setTimeout(c, 500); };
c();
});
// Check captcha (only if visible on screen, not hidden SDK at top:-1000000)
const outer = document.querySelector('#tcaptcha_transform_dy');
if (outer && outer.getBoundingClientRect().top >= 0) return { error: 'captcha' };
// Fill and submit (verified selectors: input.search-input, input.search-btn)
const input = document.querySelector('input.search-input');
input.value = query;
input.dispatchEvent(new Event('input', { bubbles: true }));
document.querySelector('input.search-btn')?.click();
// Wait for results
await new Promise((r, j) => {
let n = 0;
const c = () => { if (document.body.innerText.includes('条结果')) r(); else if (++n > 30) j('timeout'); else setTimeout(c, 500); };
c();
});
// Check captcha again
const outer2 = document.querySelector('#tcaptcha_transform_dy');
if (outer2 && outer2.getBoundingClientRect().top >= 0) return { error: 'captcha' };
// Extract current page results (merged parse-results)
const rows = document.querySelectorAll('.result-table-list tbody tr');
const checkboxes = document.querySelectorAll('.result-table-list tbody input.cbItem');
const results = Array.from(rows).map((row, i) => {
const titleLink = row.querySelector('td.name a.fz14');
const authors = Array.from(row.querySelectorAll('td.author a.KnowledgeNetLink') || []).map(a => a.innerText?.trim());
const journal = row.querySelector('td.source a')?.innerText?.trim() || '';
const date = row.querySelector('td.date')?.innerText?.trim() || '';
const citations = row.querySelector('td.quote')?.innerText?.trim() || '';
const downloads = row.querySelector('td.download')?.innerText?.trim() || '';
return {
n: i + 1,
title: titleLink?.innerText?.trim() || '',
href: titleLink?.href || '',
exportId: checkboxes[i]?.value || '',
authors: authors.join('; '),
journal,
date,
citations,
downloads
};
});
return {
query,
total: document.querySelector('.pagerTitleCell')?.innerText?.match(/([\d,]+)/)?.[1] || '0',
page: document.querySelector('.countPageMark')?.innerText || '1/1',
results
};
}Searched CNKI for "$ARGUMENTS": found {total} results (page {page}).
1. {title}
Authors: {authors} | Journal: {journal} | Date: {date}
Citations: {citations} | Downloads: {downloads}
2. ...navigate_pagehref#tcaptcha_transform_dygetBoundingClientRect().top >= 0top: -1000000pxerror: 'captcha'top >= 0| Element | Selector | Notes |
|---|---|---|
| Search input | | id= |
| Search button | | type="button" |
| Result count | | text "共找到 X 条结果" |
| Page indicator | | text "1/300" |
| Result rows | | Each row = one paper |
| Title link | | Paper title with href |
| Authors | | Author name links |
| Journal | | Journal/source link |
| Date | | Publication date text |
| Citations | | Citation count |
| Downloads | | Download count |
exportId#export-idcnki-export