NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

Glossary

DOM: the live structure of a web page

The Document Object Model (DOM) is the in memory tree of elements, attributes and text that a browser builds from a page and that scripts can read and change.

Definition

When a browser receives HTML, it parses it into a tree of nodes: the document at the root, then html, head, body and every element below them. That tree is the DOM. It is also an API: JavaScript can query nodes, change their text, add or remove elements and listen for events. What you see on screen is drawn from the DOM, not from the original HTML text.

Static HTML versus the live DOM

The difference between these two is the single most common cause of "my selector works in the browser but not in my script".

  • Static HTML is the response body from the server. An HTTP client sees only this.
  • The live DOM is that HTML after parsing, after scripts have run, after background requests filled in content, and after user actions such as scrolling or clicking.

On a server rendered page, the two are nearly identical. On a single page app, the static HTML may contain little more than an empty <div id="root"> and some script tags, while the DOM ends up holding the whole product list. The browser's "View source" shows the static HTML; the Elements panel in developer tools shows the live DOM.

Checking which one you have

  1. Fetch the URL with curl or your HTTP client and search the body for a value you see on screen.
  2. If it is there, a parser on the static HTML is enough, and it is faster and cheaper.
  3. If it is missing, the content arrives later. Look in the network panel for a JSON request that carries it, or use a browser for JavaScript rendering.

Reading the DOM in a browser automation tool

// Playwright (Node): wait for the rendered list, then read it
await page.goto("https://example.com/deals");
await page.locator("ul.deals li").first().waitFor();
const deals = await page.$$eval("ul.deals li", (items) =>
  items.map((li) => ({
    title: li.querySelector("h4")?.textContent?.trim(),
    url: li.querySelector("a")?.href,
  }))
);

Inside $$eval the callback runs in the page, against the live DOM, so properties like href already hold absolute URLs.

Shadow DOM and iframes

Two structures hide parts of the tree. Web components can attach a shadow root whose contents ordinary selectors do not reach unless the tool pierces it; Playwright locators do by default for open shadow roots. Iframes hold a separate document with its own DOM. CAPTCHA widgets often live in iframes: the reCAPTCHA checkbox and the Turnstile widget render inside frames from Google and Cloudflare, so you cannot read their state from the outer DOM.

The DOM and solving

To solve a widget, you need its parameters, which live in the outer DOM: the data-sitekey attribute, the hidden response field, and sometimes a callback name. After a reCAPTCHA v2 task returns a token, you write it into the hidden g-recaptcha-response textarea in the DOM, or pass it to the page's callback, and submit. The g-recaptcha-response entry covers that field.

Common questions

Is the DOM the same as the page source?

No. The source is the HTML the server sent, while the DOM is the live tree after parsing and after scripts have changed it.

Why can my HTTP client not see elements I see in the browser?

Those elements were added by JavaScript after the page loaded, so they exist only in the live DOM.

How do I read the live DOM from code?

Use a browser automation tool such as Playwright, Puppeteer or Selenium and query elements after the page has rendered.

Why can I not reach elements inside a CAPTCHA widget?

Widgets usually render in iframes from another origin, which have their own separate document and DOM.

Where does a solved token go in the DOM?

Usually into a hidden response field such as g-recaptcha-response, or it is passed to a callback the page defined.

Keep reading