Skip to main content

Get Value

Extracts the text content or attribute value from an HTML element using a CSS selector.

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

  • Element - The HTML content to search within.
  • CSS Selector - The CSS selector pattern to match an element (optional).
  • Attribute Name - The name of the attribute to extract (optional).

Options

This node does not have any options.

Output

  • Value - The extracted text content or attribute value.

How It Works

The Get Value node extracts either the text content or a specific attribute value from an HTML element. When executed, the node:

  1. Retrieves the Element, CSS Selector, and Attribute Name input variables
  2. Validates that the Element input is not empty
  3. Parses the HTML content into a goquery document
  4. Applies the CSS selector if provided:
    • If CSS Selector is empty, uses the entire document
    • If CSS Selector is provided, finds elements matching the selector
  5. Extracts the value based on the Attribute Name:
    • If Attribute Name is empty, extracts the text content of the selected element(s)
    • If Attribute Name is provided, extracts the value of that attribute from the selected element(s)
  6. Sets the extracted value as the output variable

Requirements

  • Valid HTML content to search within
  • Non-empty Element input

Error Handling

The node will return specific errors in the following cases:

  • Empty or invalid Element input - "HTML input cannot be empty"
  • Malformed HTML that cannot be parsed

Usage Notes

  • If CSS Selector is empty, operates on the entire HTML document
  • If CSS Selector is provided, operates on elements matching that selector
  • If Attribute Name is empty, extracts the text content of the element
  • If Attribute Name is provided, extracts the value of that specific attribute
  • Returns an empty string if the attribute doesn't exist or if no text content is found
  • Useful for extracting specific data points from HTML elements
  • Can extract common attributes like href, src, alt, title, class, id, etc.
  • Works with both simple and complex HTML structures
  • The CSS Selector can match multiple elements, but only the first match is used
  • When extracting text content, removes HTML tags and returns only the text
  • When extracting attribute values, returns the exact value as it appears in the HTML