Dynamic content extraction

From AtlasOmnia/hermes-custom-pack · View interactive version

Dynamic content extraction is an AI agent skill from the GitHub repository AtlasOmnia/hermes-custom-pack. dynamic-content-extraction — Extract structured data from JavaScript-heavy sites where prices, text, or key fields don't appear in the standard accessibility tree. Covers browser_snapshot(full=true), TreeWalker text-node extraction, lazy-load handling, and React split-text recovery.

How to use this skill

Skill file

Dynamic Content Extraction

Extract structured data (prices, listings, product details) from JavaScript-heavy sites where key data is rendered by React/Vue/Angular and doesn't appear in compact accessibility snapshots.

When to Use

References:

Workflow

1. Start with full snapshot

browser_snapshot(full=true) — compact mode (full=false, the default) often omits dynamically-injected prices and numbers. Full mode surfaces text from the complete accessibility tree.

Pitfall: Full snapshots on listing pages are often truncated (300-500 lines). Accept this and scroll + re-extract in batches.

2. Scroll to trigger lazy loading

Modern sites (IHG, Airbnb, Expedia) only render ~5-15 cards initially. Scroll 4-6 times before extraction:

browser_scroll(direction='down') # repeat 3-6 times

Then wait 2-3 seconds for React to hydrate new cards.

3. Extract via TreeWalker (React split-text recovery)

React and similar frameworks often split text across sibling elements. Example from IHG:

<span><span>156</span><span> USD</span></span>

The number "156" and "USD" are separate text nodes — regex on parent textContent works but may merge adjacent values.

Preferred pattern — TreeWalker for leaf text nodes:

(() => {
 const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
 const results = [];
 let node;
 while (node = walker.nextNode()) {
 const text = node.textContent.trim();
 // Match data patterns (prices, ratings, etc.)
 if (/^\d{2,4}$/.test(text) && node.parentElement.textContent.includes('USD')) {
 const price = parseInt(text);
 // Walk up to find container card
 let card = node.parentElement;
 for (let i = 0; i < 15 && card; i++) {
 const h2 = card.querySelector('h2');
 if (h2) {
 results.push({ name: h2.textContent.trim(), price });
 break;
 }
 card = card.parentElement;
 }
 }
 }
 return results;
})()

4. Walk up from data nodes to cards

Data nodes (price, rating) live deep inside React component trees. Walk up 10-15 levels to find the card container, then query inside it for other fields (name, distance, reviews).

Pattern:

price text node → parent → ... (walk up) → card container → querySelector('h2')

5. Cross-validate with snapshot data

Use browser_snapshot to cross-check hotel names and amenities, since the accessibility tree reliably captures headings and static text labels — just not the prices.

6. Discover and query same-origin frontend data APIs

When the page offers a useful sort/filter but the accessibility tree omits the underlying numbers:

  1. Inspect performance.getEntriesByType('resource') for same-origin frontend/API requests.
  2. If the UI's internal sort value is unclear, search loaded JavaScript chunks for the visible option label and recover its enum or query parameter.
  3. Reproduce the request with fetch() inside browser_console, inspect the response shape, then join records through stable IDs rather than parsing rendered cards.
  4. Preserve metric window, percentile, sample count, provider, and units in the result. Live rankings without those fields are easy to overstate.
  5. Classify specialized entries before recommending them; a raw throughput leader may be a moderation, image, code-apply, or multi-agent model rather than a general assistant.

Pitfalls

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.