agentleFS
lintendolintendo/Axhub-Skills/skills/extract-page-data/SKILL.md

extract-page-data

Skill145 starsChanged 19 days agoMITView on GitHub

Extract structured data from any web page using Playwright — screenshots, design tokens, page text as Markdown, interactive element maps, and full page data packs. Use this skill whenever the user wants to capture a web page screenshot (full page or element), extract CSS design tokens or theme information, convert page content to Markdown, collect links and interactive elements from a page, or export a complete page analysis package. Triggers on any URL that isn't an Axure prototype — for Axure URLs use extract-axure-data instead.

  • Installs packages

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

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

    line 23
  2. Very specific:

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

    line 91
  3. Distinctive:

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

    line 221
  4. Very specific:

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

    line 251

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.