Get Values
Extracts text content or attribute values from multiple HTML elements 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
- Elements - An array of HTML elements to process.
- CSS Selector - The CSS selector pattern to match elements within each HTML element (optional).
- Attribute Name - The name of the attribute to extract from each element (optional).
Options
This node does not have any options.
Output
- Values - An array of strings containing the extracted text content or attribute values.
How It Works
The Get Values node extracts either the text content or a specific attribute value from multiple HTML elements. When executed, the node:
- Retrieves the Elements array, CSS Selector, and Attribute Name input variables
- Iterates through each HTML element in the Elements array
- For each element:
- Parses the HTML content into a goquery document
- 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
- 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)
- Collects the extracted value in an output array
- Sets the array of extracted values as the output variable
Requirements
- Valid HTML elements in the Elements array
- Non-empty Elements input
Error Handling
The node will return specific errors in the following cases:
- Malformed HTML that cannot be parsed in any element - "Element parse error"
Usage Notes
- Processes each HTML element in the input array independently
- If CSS Selector is empty, operates on the entire HTML document for each element
- If CSS Selector is provided, operates on elements matching that selector within each HTML element
- If Attribute Name is empty, extracts the text content of each element
- If Attribute Name is provided, extracts the value of that specific attribute from each element
- Returns an array of values with the same length as the input Elements array
- For elements where the attribute doesn't exist or no text content is found, returns an empty string at that position
- Useful for batch processing of multiple HTML elements to extract similar data points
- Can extract common attributes like
href
,src
,alt
,title
,class
,id
, etc. - Works with both simple and complex HTML structures
- 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
- Maintains the order of values corresponding to the input elements