Cnki Download

cookjohn/cnki-skills/skills/cnki-download

作者 cookjohn20d65f660456daf53ad0f7c74494ac3b829b925f无许可证983 个星标收录于 2026年10月9日更新于 2026年10月9日仓库7个月前更新

Download a paper PDF/CAJ from CNKI. Requires user to be logged in. Use when user wants to download a specific paper.

AI 生成的概览

通过浏览器自动化从 CNKI 论文详情页下载论文的 PDF 或 CAJ 文件。

功能
该技能指导智能体从 CNKI 下载指定论文:先导航到论文详情页 URL,再运行浏览器脚本等待页面加载、检查验证码和登录状态,然后点击 PDF 或 CAJ 下载链接。它会报告论文标题以及是否已触发下载,或返回未登录、需要验证码、未找到下载链接等错误。文档还列出了已验证的页面选择器和验证码检测逻辑。
适用场景
当用户希望下载某篇具体的 CNKI 论文,且已登录并具备下载权限时使用。适用于用户提供论文详情页 URL 或已停留在论文详情页的情况。
运行要求
需要具备 navigate_page 和 evaluate_script 工具的浏览器自动化环境、已登录且具有下载权限的 CNKI 账号,以及访问 CNKI 的网络连接。该技能不附带脚本,仅为操作说明。

CNKI Paper Download (文献下载)

Prerequisites

User must be logged in to CNKI with download permissions.

Arguments

$ARGUMENTS is optionally a paper detail URL. If blank, uses current page.

Steps

1. Navigate (if URL provided)

If URL provided: use navigate_page to go to the URL directly (no wait_for needed — Step 2 handles waiting).

Important: Always use navigate_page instead of clicking links on the search results page. Clicking opens a new tab and wastes 3 extra tool calls (list_pages + select_page + take_snapshot).

2. Check status and download (single async evaluate_script)

Replace FORMAT with "pdf" or "caj":

javascript
async () => {  // Wait for page load  await new Promise((r, j) => {    let n = 0;    const c = () => {      if (document.querySelector('.brief h1')) r();      else if (++n > 30) j('timeout');      else setTimeout(c, 500);    };    c();  });
  // Captcha check  const cap = document.querySelector('#tcaptcha_transform_dy');  if (cap && cap.getBoundingClientRect().top >= 0) {    return { error: 'captcha', message: 'CNKI 正在显示滑块验证码。请在 Chrome 中手动完成拼图验证。' };  }
  const format = "FORMAT"; // "pdf" or "caj"
  // Check download links  const pdfLink = document.querySelector('#pdfDown') || document.querySelector('.btn-dlpdf a');  const cajLink = document.querySelector('#cajDown') || document.querySelector('.btn-dlcaj a');
  // Check login status  const notLogged = document.querySelector('.downloadlink.icon-notlogged')    || document.querySelector('[class*="notlogged"]');  if (notLogged) {    return { error: 'not_logged_in', message: '下载需要登录。请先在 Chrome 中登录知网账号。' };  }
  const title = document.querySelector('.brief h1')?.innerText?.trim()?.replace(/\s*网络首发\s*$/, '') || '';
  if (format === 'pdf' && pdfLink) {    pdfLink.click();    return { status: 'downloading', format: 'PDF', title };  } else if (format === 'caj' && cajLink) {    cajLink.click();    return { status: 'downloading', format: 'CAJ', title };  } else if (pdfLink) {    pdfLink.click();    return { status: 'downloading', format: 'PDF', title };  } else if (cajLink) {    cajLink.click();    return { status: 'downloading', format: 'CAJ', title };  }
  return { error: 'no_download', message: '未找到下载链接', hasPDF: !!pdfLink, hasCAJ: !!cajLink };}

3. Report

Based on JS result:

  • status: downloading → "PDF 下载已触发:{title}。请在 Chrome 下载管理器中查看。"
  • error: not_logged_in → tell user to log in
  • error: captcha → tell user to solve captcha

Tool calls: 1–2 (navigate_page if URL + evaluate_script)

Verified selectors

ElementSelectorNotes
PDF download#pdfDown<a> inside li.btn-dlpdf
CAJ download#cajDown<a> inside li.btn-dlcaj
Download area.download-btnsparent <div>
Not logged in.downloadlink.icon-notlogged
Title.brief h1strip trailing "网络首发"

Captcha detection

Check #tcaptcha_transform_dy element's getBoundingClientRect().top >= 0. Only active when top >= 0 (visible). Pre-loaded SDK sits at top: -1000000px.

来源与署名

来源:cookjohn/cnki-skills位于skills/cnki-download提交20d65f6

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架