Back to Skills

知网文献关键词检索

通过浏览器自动化在 CNKI 按关键词检索论文,返回结构化结果并可导出到 Zotero。

Version: 1.0.4Contributor: @org-b6kzcl68Category: 深度研究
CNKIZotero中文说明学术论文检索

Use “知网文献关键词检索” in Tokeny

  1. Download the Tokeny app
  2. Install this skill in one click
  3. Use it directly in chat
Already installed? Open in Tokeny

SKILL.md

CNKI 基础检索

用关键词在知网(CNKI)检索论文。单次调用即可返回结果总数和结构化的结果列表(标题、URL、作者、期刊、日期)。

参数

$ARGUMENTS 为中文或英文的检索关键词。

步骤

1. 页面跳转

使用 mcp__chrome-devtools__navigate_page → https://kns.cnki.net/kns8s/search

2. 搜索并提取结果(单个 evaluate_script,不要用 wait_for)

把 YOUR_KEYWORDS 替换为实际检索词:

async () => {
  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
  };
}

3. 汇报结果

以编号列表形式呈现结果:

Searched CNKI for "$ARGUMENTS": found {total} results (page {page}).

1. {title}
   Authors: {authors} | Journal: {journal} | Date: {date}
   Citations: {citations} | Downloads: {downloads}

2. ...

4. 后续操作:跳转到某篇论文

当用户想打开或下载某篇具体论文时,直接使用 navigate_page 并传入结果的 href URL——不要点击链接(点击会打开新标签页,浪费 3 次额外的标签页管理工具调用)。

验证码检测

检查 #tcaptcha_transform_dy 元素的 getBoundingClientRect().top >= 0。 腾讯验证码 SDK 会在 top: -1000000px(屏幕外、未激活)预加载 DOM。 只有当 top >= 0(真正对用户可见)时才返回 error: 'captcha'。

已验证的选择器

元素选择器说明
搜索输入框input.search-inputid=txt_search,placeholder 为「中文文献、外文文献」
搜索按钮input.search-btntype="button"
结果总数.pagerTitleCell文本「共找到 X 条结果」
页码指示.countPageMark文本「1/300」
结果行.result-table-list tbody tr每行 = 一篇论文
标题链接td.name a.fz14带href的论文标题
作者td.author a.KnowledgeNetLink作者姓名链接
期刊td.source a期刊/来源链接
日期td.date发表日期文本
被引量td.quote引用次数
下载量td.download下载次数

批量导出到 Zotero

当用户想把结果保存到 Zotero 时,直接从结果页使用批量导出——不要逐个跳转到详情页。结果中的 exportId 等于详情页的 #export-id。以批量模式(Step 1B)调用 cnki-export 技能。详见 cnki-export 的 SKILL.md。

工具调用:2 次(navigate + evaluate_script)

What is Tokeny?

  • A free desktop AI assistant for Windows, macOS and Linux.
  • Describe a task to process files, create documents and spreadsheets, or run multi-step work.
  • Extend it with skills and MCP servers installed from the marketplace in one click.
Learn about Tokeny

评论与讨论

0/2000

还没有评论,分享你的体验吧。