GetHTMLElement

Description:

Extracts HTML element values from the incoming flowfile's content using a CSS selector. The incoming HTML is first converted into a HTML Document Object Model so that HTML elements may be selected in the similar manner that CSS selectors are used to apply styles to HTML. The resulting HTML DOM is then "queried" using the user defined CSS selector string. The result of "querying" the HTML DOM may produce 0-N results. If no results are found the flowfile will be transferred to the "element not found" relationship to indicate so to the end user. If N results are found a new flowfile will be created and emitted for each result. The query result will either be placed in the content of the new flowfile or as an attribute of the new flowfile. By default the result is written to an attribute. This can be controlled by the "Destination" property. Resulting query values may also have data prepended or appended to them by setting the value of property "Prepend Element Value" or "Append Element Value". Prepended and appended values are treated as string values and concatenated to the result retrieved from the HTML DOM query operation. A more thorough reference for the CSS selector syntax can be found at "http://jsoup.org/apidocs/org/jsoup/select/Selector.html"

Tags:

get, html, dom, css, element

Properties:

In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

NameDefault ValueAllowable ValuesDescription
URLBase URL for the HTML page being parsed. This URL will be used to resolve an absolute URL when an attribute value is extracted from a HTML element.
Supports Expression Language: true
CSS SelectorCSS selector syntax string used to extract the desired HTML element(s).
Supports Expression Language: true
HTML Character EncodingUTF-8Character encoding of the input HTML
Output TypeHTML
  • HTML
  • Text
  • Attribute
  • Data
Controls the type of DOM value that is retrieved from the HTML element.
Destinationflowfile-attribute
  • flowfile-attribute
  • flowfile-content
Control if element extracted is written as a flowfile attribute or as flowfile content.
Prepend Element ValuePrepends the specified value to the resulting Element
Supports Expression Language: true
Append Element ValueAppends the specified value to the resulting Element
Supports Expression Language: true
Attribute NameWhen getting the value of a HTML element attribute this value is used as the key to determine which attribute on the selected element should be retrieved. This value is used when the "Output Type" is set to "Attribute". If this value is prefixed with 'abs:', then the extracted attribute value will be converted into an absolute URL form using the specified base URL.
Supports Expression Language: true

Relationships:

NameDescription
element not foundElement could not be found in the HTML document. The original HTML input will remain in the FlowFile content unchanged. Relationship 'original' will not be invoked in this scenario.
successSuccessfully parsed HTML element
originalThe original HTML input
invalid htmlThe input HTML syntax is invalid

Reads Attributes:

None specified.

Writes Attributes:

NameDescription
HTMLElementFlowfile attribute where the element result parsed from the HTML using the CSS selector syntax are placed if the destination is a flowfile attribute.

State management:

This component does not store state.

Restricted:

This component is not restricted.

Input requirement:

This component requires an incoming relationship.

See Also:

ModifyHTMLElement, PutHTMLElement