mcpField
C
cnki-parse-results

cnki-parse-results

github.com/cookjohn生産性1.0k387 回インストール33 週間前に更新
リポジトリ

cnki-parse-results について

現在のCNKI検索結果ページから論文情報を構造化して抽出するスキルです。著者、掲載誌、引用数などを含む検索結果を整理する用途に向いています。

主な機能

  1. 01検索結果の論文一覧を読み取り
  2. 02タイトル、著者、掲載誌を抽出
  3. 03日付、文献種別、引用数を取得
  4. 04オンライン先行公開の表示を識別

活用シーン

  1. 01現在のCNKI検索結果をまとめる
  2. 02掲載誌と公開日の比較
  3. 03引用数とダウンロード数の整理

MCP 対応

Chrome DevTools MCPで現在のページを確認し、JavaScriptで結果を抽出します。ページ構造を利用できない場合はスナップショット解析に切り替えられます。

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/cookjohn/cnki-skills --skill cnki-parse-results

インストール後、Claude Code で/cnki-parse-resultsを入力して読み込まれたか確認します。

詳細

CNKI 検索結果の解析

現在の CNKI 検索結果ページから、論文データを構造化して抽出します。

前提条件

現在の Chrome ページが CNKI の検索結果ページである必要があります(URL に kns.cnki.net が含まれ、ページに「条结果」と表示されていること)。

手順

1. 検索結果ページであることを確認する

mcp__chrome-devtools__take_snapshot を使用します。ページに「条结果」が含まれていることを確認してください。含まれていない場合は、現在検索結果ページが開かれていないことをユーザーに伝えます。

CAPTCHA(「拖动下方拼图完成验证」)がないか確認します。見つかった場合は、手動で解決するようユーザーに伝えます。

2. JavaScript で結果を抽出する

次の関数を指定して mcp__chrome-devtools__evaluate_script を使用します。

() => {
  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, index) => {
    const nameCell = row.querySelector('td.name');
    const titleLink = nameCell?.querySelector('a.fz14');
    const authorCell = row.querySelector('td.author');
    const sourceCell = row.querySelector('td.source');
    const dateCell = row.querySelector('td.date');
    const dataCell = row.querySelector('td.data');
    const quoteCell = row.querySelector('td.quote');
    const downloadCell = row.querySelector('td.download');
    const isOnlineFirst = !!nameCell?.querySelector('.marktip');

    return {
      number: index + 1,
      title: titleLink?.innerText?.trim() || '',
      url: titleLink?.href || '',
      exportId: checkboxes[index]?.value || '',
      authors: Array.from(authorCell?.querySelectorAll('a.KnowledgeNetLink') || []).map(a => a.innerText?.trim()),
      journal: sourceCell?.querySelector('a')?.innerText?.trim() || '',
      date: dateCell?.innerText?.trim() || '',
      database: dataCell?.innerText?.trim() || '',
      citations: quoteCell?.innerText?.trim() || '',
      downloads: downloadCell?.innerText?.trim() || '',
      isOnlineFirst: isOnlineFirst
    };
  });

  const totalText = document.querySelector('.pagerTitleCell')?.innerText || '';
  const totalMatch = totalText.match(/([\d,]+)/);
  const pageInfo = document.querySelector('.countPageMark')?.innerText || '';

  return {
    papers: results,
    totalCount: totalMatch ? totalMatch[1] : 'unknown',
    pageInfo: pageInfo
  };
}
3. 結果を表示する

番号付きリストとして整形します。

CNKI search results ({totalCount} total, page {pageInfo}):

1. {title} {isOnlineFirst ? "[网络首发]" : ""}
   Authors: {authors joined by "; "}
   Journal: {journal} | Date: {date} | Type: {database}
   Citations: {citations} | Downloads: {downloads}
   URL: {url}

2. ...
4. フォールバック:スナップショットに基づく解析

JavaScript の戻り値が空の場合(DOM 構造が変更されている場合)は、mcp__chrome-devtools__take_snapshot を使用し、アクセシビリティツリーを手動で解析します。

繰り返し現れる次のパターンを探します。

  • checkbox → StaticText(番号)→ URL に kcms2/article/abstract を含む link(タイトル)→ URL に kcms2/author/detail を含む link(著者)→ URL に navi.cnki.net/knavi/detail を含む link(ジャーナル)→ StaticText(日付)→ StaticText(データベースの種類)

検証済み DOM セレクター(CNKI は jQuery を使用しており、意味的なクラス名は安定しています)

データセレクター備考
表.result-table-list tbody tr各行 = 1 件の論文
チェックボックスinput.cbItemvalue = エクスポート用の暗号化 ID
番号td.seq行の連番
タイトルtd.name a.fz14論文タイトルへのリンク
著者td.author a.KnowledgeNetLink著者名へのリンク
ジャーナルtd.source aジャーナル/ソースへのリンク
日付td.date発行日テキスト
DB の種類td.dataデータベースの種類(期刊/学位论文)
引用数td.quote被引用数
ダウンロード数td.downloadダウンロード数
オンライン先行公開td.name .marktip「网络首发」ラベル
合計.pagerTitleCell「共找到 X 条结果」
ページ.countPageMark「1/300」形式

コメント