For the complete documentation index, see llms.txt. This page is also available as Markdown.

Capture DOM

Type: capture_dom

This action will capture and return the site's raw DOM, which you can then extract data from on your end.

For common AI scenarios, you may find that this returns too much data, so we have provided a generate_simplified_dom , an action that distils the DOM to only the important elements.

Tips for using cature_dom action
  • Use it when you want to parse the page yourself with a traditional HTML library such as BeautifulSoup, lxml, or Cheerio.

  • It can also be used for debugging. When a selector isn't matching, the raw DOM shows you what's actually on the page.

  • Use it when you need something the other actions strip out, like inline scripts, data- attributes or full link URLs.

  • Don't send the output to an LLM. Use generate_simplified_dom or generate_markdown instead, which carry the same information for far fewer tokens.

  • It captures the page as it is at that point in the run, so you can use it multiple times to compare the state before and after an interaction.

  • If content is missing from the capture, the page probably hadn't finished loading. Add a wait before it.

Parameters

See universal parameters.

Usage

Capture the raw DOM of the current page

"actions": [
    {
      "type": "capture_dom"
    }
]

Example Output

FAQs

When do I use the capture_dom action?

Use it when you want to parse the page yourself with a library like BeautifulSoup, or when you need scripts, attributes and link query strings that the simplified and Markdown outputs remove. See our guide to scraping tables with Python.

What does capture_dom action return?

It returns the page's raw DOM as the browser rendered it, including scripts, styles and every attribute. This is the page after JavaScript has run, not the original server HTML.

Why is content missing from my capture_dom output?

The action probably ran before the page finished loading. Add a wait action with a selector for the content you're expecting, so Gaffa captures the page once it's there.

When should I use generate_simplified_dom instead of capture_dom?

Use generate_simplified_dom whenever the output goes to an LLM, or you're looking for selectors. It keeps the page structure but removes the scripts and styling that make raw DOM so large. See our guide to simplifying a webpage DOM.

Why is my capture_dom output so big?

Raw DOM includes all scripts and styles on the page. Use generate_simplified_dom to strip those out, or capture_element with a selector to capture only the part you need.

How do I capture only part of the page with capture_dom action?

Use capture_element with a selector instead. It gives you the same raw HTML, but only for the element you point it at.

Last updated