mcpField
E
extract-page-data

extract-page-data

github.com/lintendoデザイン・UI137140 回インストール3 日前に更新
リポジトリ

extract-page-data について

extract-page-data は、Web ページの内容やデザイン情報を収集するコマンドラインスキルです。スクリーンショット、デザイントークン、Markdown テキスト、操作要素を出力し、セレクターで対象を絞れます。

主な機能

  1. 01ページ全体や要素のスクリーンショット
  2. 02CSS からデザイントークンを抽出
  3. 03ページ内容を Markdown に変換
  4. 04リンクと操作要素の収集
  5. 05結果を ZIP データパックに出力

活用シーン

  1. 01Web サイトのビジュアルデザインの確認
  2. 02デザイントークンを使ったページ再構築
  3. 03ページ内容と操作要素の調査
  4. 04ログイン必須ページや遅延読み込み内容の取得

インストール

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

$npx skills add https://github.com/lintendo/axhub-skills --skill extract-page-data

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

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

scripts/
extract.mjs
scripts/inject/
extract-links.js
extract-markdown.js
extract-theme.js
README.md
scripts/lib/
browser.mjs
links.mjs
markdown.mjs
pack.mjs
screenshot.mjs
theme.mjs

詳細

ページデータの抽出

デザイン分析、ページの再構築、コンテンツのレビューに向けて、あらゆるウェブページから構造化データを抽出します。スクリプトが依存関係のインストールを自動で処理するので、URLを指定するだけです。

使用する場面

  • ユーザーがウェブページのURLを共有し、スクリーンショットの撮影を希望している
  • ページからデザイントークン、CSSテーマ、またはカラーパレットを抽出したい
  • ページのコンテンツをMarkdownテキストとして取得したい
  • ページにあるリンク、ボタン、インタラクティブな要素を確認したい
  • あらゆるウェブページの構造をエクスポートまたは分析したい
  • ページ上の特定の要素のスクリーンショットを撮影したい(--selectorを使用)

Axureのプロトタイプには使用しないでください。代わりにextract-axure-dataを使用してください。

クイックスタート

このスキルのディレクトリからの相対パスで、scripts/extract.mjsにある抽出スクリプトを実行します。

# Full page screenshot
node scripts/extract.mjs https://example.com --screenshot

# Screenshot of a specific element
node scripts/extract.mjs https://example.com --screenshot --selector "#hero"

# Extract design tokens (colors, typography, spacing, etc.)
node scripts/extract.mjs https://example.com --theme

# Extract page content as Markdown
node scripts/extract.mjs https://example.com --markdown

# Collect all links and interactive elements
node scripts/extract.mjs https://example.com --links

# Extract everything
node scripts/extract.mjs https://example.com --all

# Export full data pack (screenshot + theme + markdown + links as zip)
node scripts/extract.mjs https://example.com --pack

初回実行時に、PlaywrightとChromiumが~/.cache/page-extractor/に自動インストールされます。これには1~2分かかり、インストールは一度だけです。

パラメーター

フラグ説明デフォルト
<url>ウェブページのURL(必須)—
--screenshotページのスクリーンショットを撮影オフ
--themeデザイントークンを抽出オフ
--markdownページをMarkdownに変換オフ
--linksインタラクティブな要素を収集オフ
--packデータ一式をエクスポート(zip)オフ
--allすべての抽出を実行オフ
--selector SEL抽出対象を指定するCSSセレクターページ全体
-o DIR出力ディレクトリ./page-export
--viewport WxHビューポートのサイズ1280x720
--wait MSページ読み込み後の追加待機時間(ms)0
--scrollページをスクロールして遅延読み込みコンテンツを表示オフ
--scroll-step PXスクロール1回あたりのピクセル数800
--scroll-delay MSスクロール間の遅延時間(ms)200
--no-headlessブラウザーウィンドウを表示ヘッドレス
--connect-cdp URL実行中のChromeに接続(認証用)—
--format FMTスクリーンショット形式:pngまたはjpegpng
--verbose詳細なログを表示オフ

出力構造

page-export/
├── screenshot.png       # Page or element screenshot    (--screenshot)
├── theme.json           # Design tokens                 (--theme)
├── content.md           # Page text as Markdown          (--markdown)
├── links.json           # Links and interactive elements (--links)
└── page-data.zip        # Full data pack                 (--pack)
    ├── screenshot.png
    ├── theme.json
    ├── content.md
    ├── links.json
    └── meta.json        # Page metadata (title, url, viewport)

セレクターのサポート

すべての抽出モードで--selectorを指定し、特定の要素に対象を絞れます。

# Screenshot only the header
node scripts/extract.mjs https://example.com --screenshot --selector "header"

# Extract design tokens from a card component
node scripts/extract.mjs https://example.com --theme --selector ".card"

# Get Markdown from the main content area
node scripts/extract.mjs https://example.com --markdown --selector "main"

# Collect links from the navigation
node scripts/extract.mjs https://example.com --links --selector "nav"

認証が必要なページ

ページによってはログインが必要です。方法は2つあります。

既存のChromeセッションに接続する(推奨 — Cookieを再利用します):

macOS:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222

Windows:

start chrome --remote-debugging-port=9222

その後、そのChromeウィンドウからログインして、次を実行します。

node scripts/extract.mjs https://example.com --all --connect-cdp http://localhost:9222

ブラウザーウィンドウを表示する(抽出中に手動でログイン):

node scripts/extract.mjs https://example.com --all --no-headless

依存関係のインストール

初回実行時にスクリプトが自動インストールします。失敗した場合:

# Manual install
cd ~/.cache/page-extractor
npm install playwright
npx playwright install chromium

# If Chromium download is slow (e.g. behind GFW):
PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright npx playwright install chromium

出力データ形式

theme.json

計算済みCSSスタイルから抽出されたデザインシステムのトークン:

{
  "colors": {
    "background": [{"value": "rgb(255,255,255)", "count": 42, "tags": ["div"]}],
    "text": [{"value": "rgb(51,51,51)", "count": 28, "tags": ["p","span"]}],
    "border": [{"value": "rgb(221,221,221)", "count": 12}]
  },
  "typography": {
    "families": [{"value": "\"Inter\", sans-serif", "count": 56}],
    "textStyles": [{"size": "14px", "lineHeight": "22px", "weight": "400", "count": 20}]
  },
  "spacing": [{"value": "16px", "count": 15}],
  "radius": [{"value": "4px", "count": 8}],
  "lineWidth": [{"value": "1px", "count": 10}],
  "shadow": {
    "box": [{"value": "0 2px 8px rgba(0,0,0,0.1)", "count": 5}],
    "text": []
  },
  "transitions": [{"value": "all 0.2s ease", "count": 38, "tags": ["button","a"]}],
  "animations": [{"value": "fadeIn|0.3s|ease", "count": 5, "tags": ["div"]}],
  "cssVariables": {
    "--color-primary": "#6366f1",
    "--radius": "0.5rem",
    "--font-sans": "Inter, sans-serif"
  },
  "assets": {
    "backgroundImages": [{"value": "url(hero.webp)", "count": 1, "tags": ["section"]}],
    "images": [
      {"src": "https://example.com/logo.svg", "alt": "Logo", "position": "static", "zIndex": "auto", "siblingImgCount": 1},
      {"src": "https://example.com/hero.png", "alt": "", "position": "absolute", "zIndex": "2", "siblingImgCount": 2}
    ],
    "svgCount": 12
  }
}
links.json

ページ上のインタラクティブな要素:

{
  "pageUrl": "https://example.com",
  "pageTitle": "Example",
  "links": [
    {"type": "a", "text": "Home", "href": "https://example.com/", "visible": true},
    {"type": "button", "text": "Sign Up", "visible": true},
    {"type": "form", "href": "https://example.com/login", "visible": true}
  ],
  "totalLinks": 3,
  "visibleLinks": 3
}

カスタマイズ

抽出ロジックはモジュール式です。各機能はScripts/の下にある個別のファイルに実装されています。

ファイル役割カスタマイズ
lib/browser.mjsPlaywrightブラウザーの管理ブラウザーの起動引数、プロキシを変更
lib/screenshot.mjsスクリーンショットの撮影スクロール動作、形式を変更
lib/theme.mjsデザイントークンの抽出トークンのカテゴリ、上限を調整
lib/markdown.mjsHTML → Markdown変換ルールを変更
lib/links.mjs要素の収集新しい要素タイプを追加
lib/pack.mjszipパッケージ化パッケージの内容を変更
inject/extract-theme.jsブラウザーに挿入されるテーマロジック抽出するCSSプロパティを編集
inject/extract-markdown.jsブラウザーに挿入されるMarkdownロジックテキスト抽出をカスタマイズ
inject/extract-links.jsブラウザーに挿入されるリンクロジックカスタムセレクターを追加

テーマ複製のワークフロー

ユーザーがウェブサイトのデザイン言語の複製を希望している場合は、次の順序で実行します。

ステップ1:すべてのデータを抽出
node extract.mjs <url> --all --scroll --viewport 1440x900
Step 2: theme.json を解釈する
フィールド対応先CSS 変数
colors.background[0]プライマリサーフェス--color-bg
colors.text[0]本文テキスト--color-text
colors.text[1]アクセント/ブランド--color-primary
typography.families[0]メインフォントGoogle Fonts のインポート
spacing(上位 5 件)スペーシングスケール--spacing-1 …
radius[0]デフォルトの角丸--radius-base
transitions[0]ホバー時のタイミング.card, a, button に適用
cssVariablesデザイントークン(:root 変数が存在する場合)名前をそのまま使用
Step 3: CSS 変数を生成する
:root {
  --color-bg:       <colors.background[0].value>;
  --color-text:     <colors.text[0].value>;
  --color-primary:  <colors.text[1].value>;
  --font-sans:      <typography.families[0].value>;
  --radius-base:    <radius[0].value>;
  --transition:     <transitions[0].value>;
}

cssVariables が空でない場合は、元のデザインシステムの意図を反映しているため、これらの名前を優先してください。

Step 4: アニメーションを復元する
  • transitions[0].value → インタラクティブ要素に transition: <value> として適用
  • animations → アニメーション名ごとに @keyframes ブロックを再構築し、エントリー要素に適用
Step 5: レイヤー化されたアセットを扱う

assets.images 内で position: absolute かつ zIndex > 0 の画像はオーバーレイレイヤーです。 親要素に CSS position: relative、オーバーレイに position: absolute を設定して再構築します。

Playwright で不足情報を補う

エクスポートデータはベストエフォートのスナップショットのため、元のページに戻って情報を補う必要がある場合があります(ホバー状態のスタイル、遅延読み込みコンテンツ、アニメーション効果など)。Playwright CLI を使用して、インタラクティブに追加情報を収集できます。

# 打开页面并获取快照
playwright-cli open https://example.com
playwright-cli snapshot

# 交互后采集(如 hover 态)
playwright-cli hover e15
playwright-cli screenshot --filename=hover-state.png

# 获取元素属性
playwright-cli eval "el => getComputedStyle(el).backdropFilter" e5

playwright-cli close

コマンドの完全なリファレンス: Playwright CLI の公式スキルドキュメント

Playwright が必要な場合
シナリオPlaywright で行うこと
スクリーンショットがぼやけている/不完全指定した要素を高解像度でスクリーンショット撮影
スタイルデータが不足している完全な computedStyle を取得
hover/focus/active 状態インタラクションを実行した後にスタイルを収集
遅延読み込みコンテンツスクロールをトリガーした後にスクリーンショット撮影
アニメーション/遷移効果時間をおいてスクリーンショット撮影、または録画
レスポンシブのブレークポイント確認viewport を設定した後にスクリーンショット撮影

トラブルシューティング

問題対処方法
スクリーンショットが真っ白ページのレンダリングに時間が必要です。--wait 2000 を追加してください
遅延読み込みコンテンツが表示されない--scroll を使用して遅延読み込みをトリガーしてください
ログインが必要--connect-cdp を使用してください(上記の「認証が必要なページ」を参照)
Playwright のインストールに失敗する手動でインストールするか、PLAYWRIGHT_DOWNLOAD_HOST を設定してください
選択した要素が違うまずブラウザーの DevTools でセレクターを確認してください

コメント