mcpField
E
extract-page-data

extract-page-data

github.com/lintendoDesign & UI137140 installsUpdated 3d ago
Repository

About extract-page-data

extract-page-data is a command-line skill for collecting web page content and design details. It exports screenshots, design tokens, Markdown text, and interactive elements, with selector-based extraction for focused analysis.

Key features

  1. 01Capture full-page or element screenshots
  2. 02Extract design tokens from CSS
  3. 03Convert page content to Markdown
  4. 04Collect links and interactive elements
  5. 05Export results as a ZIP data pack

Use cases

  1. 01Reviewing a website’s visual design
  2. 02Reconstructing a page from its design tokens
  3. 03Inspecting page content and controls
  4. 04Capturing authenticated or lazy-loaded pages

Install

Copy the command and run it in a terminal.

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

After installing, type/extract-page-datain Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with 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

Details

From the project README

Extract Page Data

Extract structured data from any web page for design analysis, page reconstruction, or content review. The script handles dependency installation automatically — just point it at a URL.

When to use this

  • User shares a web page URL and wants to capture screenshots
  • User asks to extract design tokens, CSS theme, or color palette from a page
  • User wants page content as Markdown text
  • User wants to know what links, buttons, and interactive elements are on a page
  • User asks to export or analyze any web page's structure
  • User wants to take a screenshot of a specific element on a page (use --selector)

Do NOT use for Axure prototypes — use extract-axure-data instead.

Quick start

Run the extraction script from scripts/extract.mjs relative to this skill directory.

# 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

First run auto-installs Playwright + Chromium to ~/.cache/page-extractor/. This takes 1-2 minutes and happens once.

Parameters

FlagWhat it doesDefault
<url>Web page URL (required)—
--screenshotCapture page screenshotoff
--themeExtract design tokensoff
--markdownConvert page to Markdownoff
--linksCollect interactive elementsoff
--packExport full data pack (zip)off
--allRun all extractionsoff
--selector SELCSS selector to scope extractionwhole page
-o DIROutput directory./page-export
--viewport WxHViewport size1280x720
--wait MSExtra wait after page load (ms)0
--scrollScroll page to trigger lazy contentoff
--scroll-step PXPixels per scroll step800
--scroll-delay MSDelay between scroll steps (ms)200
--no-headlessShow browser windowheadless
--connect-cdp URLAttach to running Chrome (for auth)—
--format FMTScreenshot format: png or jpegpng
--verboseDetailed loggingoff

Output structure

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 support

All extraction modes support --selector to scope to a specific element:

# 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"

Authenticated pages

Some pages require login. Two approaches:

Connect to an existing Chrome session (recommended — reuses cookies):

macOS:

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

Windows:

start chrome --remote-debugging-port=9222

Then log in via that Chrome window and run:

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

Show the browser window (manual login during extraction):

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

Dependency installation

The script auto-installs on first run. If it fails:

# 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

Output data formats

theme.json

Design system tokens extracted from computed CSS styles:

{
  "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

Interactive elements on the page:

{
  "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
}

Customization

The extraction logic is modular. Each feature lives in its own file under scripts/:

FilePurposeCustomization
lib/browser.mjsPlaywright browser managementChange browser launch args, proxy
lib/screenshot.mjsScreenshot captureModify scroll behavior, format
lib/theme.mjsDesign token extractionAdjust token categories, limits
lib/markdown.mjsHTML → MarkdownChange conversion rules
lib/links.mjsElement collectionAdd new element types
lib/pack.mjsZip packagingChange pack contents
inject/extract-theme.jsBrowser-injected theme logicEdit CSS properties to extract
inject/extract-markdown.jsBrowser-injected markdown logicCustomize text extraction
inject/extract-links.jsBrowser-injected links logicAdd custom selectors

Theme Clone Workflow

When the user wants to clone or replicate a website's design language, run in this order:

Step 1: Extract all data
node extract.mjs <url> --all --scroll --viewport 1440x900
Step 2: Interpret theme.json
FieldMaps toCSS Variable
colors.background[0]Primary surface--color-bg
colors.text[0]Body text--color-text
colors.text[1]Accent / brand--color-primary
typography.families[0]Main fontGoogle Fonts import
spacing (top 5)Spacing scale--spacing-1 …
radius[0]Default radius--radius-base
transitions[0]Hover timingapply to .card, a, button
cssVariablesDesign tokens (if :root vars exist)use names directly
Step 3: Generate CSS variables
: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>;
}

If cssVariables is non-empty, prefer those names — they reflect the original design system's intent.

Step 4: Restore animations
  • transitions[0].value → apply as transition: <value> on interactive elements
  • animations → reconstruct @keyframes blocks by animation name; apply to entry elements
Step 5: Handle layered assets

Images with position: absolute and zIndex > 0 in assets.images are overlay layers. Reconstruct with CSS position: relative on the parent and position: absolute on overlays.

Playwright 查缺补漏

导出数据是 best-effort 快照,有时需要回到原始页面补充信息(hover 态样式、懒加载内容、动画效果等)。可使用 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 后截图

Troubleshooting

ProblemFix
Blank screenshotPage needs time to render — add --wait 2000
Missing lazy contentUse --scroll to trigger lazy loading
Need loginUse --connect-cdp (see Authenticated pages above)
Playwright install failsManual install, or set PLAYWRIGHT_DOWNLOAD_HOST
Wrong element selectedCheck selector with browser DevTools first

Comments

Markdown supported