Skip to main content

Find All Elements

Finds all HTML elements that match a CSS selector and returns their outer HTML.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • HTML - The HTML content to search within.
  • CSS Selector - The CSS selector pattern to match elements.

Options

  • Contains Filter - Optional text that matched elements must contain.
  • Exclude Filter - Optional text that matched elements must not contain.

Output

  • HTML Elements - An array of strings containing the outer HTML of all matched elements.

How It Works

The Find All Elements node searches HTML content using a CSS selector and returns the outer HTML of all matching elements. When executed, the node:

  1. Retrieves the HTML and CSS Selector input variables
  2. Validates that both HTML and CSS Selector are not empty
  3. Parses the HTML content into a goquery document
  4. Applies optional filtering:
    • Contains Filter - Only includes elements that contain the specified text
    • Exclude Filter - Excludes elements that contain the specified text
  5. Finds all elements that match the CSS selector
  6. Extracts the outer HTML of each matched element
  7. Collects all outer HTML strings into an array
  8. Sets the array of HTML elements as the output variable

Requirements

  • Valid HTML content to search within
  • Valid CSS selector pattern
  • Non-empty HTML and CSS Selector inputs

Error Handling

The node will return specific errors in the following cases:

  • Empty or invalid HTML input - "HTML input can not be empty"
  • Empty or invalid CSS Selector input - "CSS Selector input can not be empty"
  • Malformed HTML that cannot be parsed - "Html data parse error"
  • No elements found matching the CSS selector - "Element not found."

Usage Notes

  • Uses standard CSS selector syntax for element matching
  • Supports complex selectors like .class, #id, tag.class, tag[attr=value], etc.
  • The Contains Filter and Exclude Filter options work on the text content of elements
  • Returns an array of outer HTML strings, preserving the complete structure of each matched element
  • Useful for web scraping, content extraction, and HTML processing tasks
  • The outer HTML includes the element's opening tag, content, and closing tag
  • Can be chained with other DOM Parser nodes to further process extracted elements
  • The order of elements in the output array matches their order in the HTML document
  • When no filters are applied, returns all elements matching the CSS selector