Skip to main content

DomLinkExtractor

Extracts links from HTML/XML documents using CSS/jQuery-style selectors.

Notesโ€‹

Extracts links from HTML, XHTML, or XML documents using CSS/jQuery-style selectors. Supports custom link selectors, extraction of specific element attributes, nofollow handling, and content-type restrictions.

Examplesโ€‹

The following example represents the default link extraction selectors with the addition of one for URLs found in custom element attributes named data-myurl.

class: DomLinkExtractor
linkSelectors:
- extract: attr(href)
selector: a[href]
- extract: attr(src)
selector: "[src]"
- extract: attr(href)
selector: link[href]
- extract: attr(content)
selector: meta[http-equiv='refresh']
- extract: attr(data-myurl)
selector: "[data-myurl]"

Usageโ€‹

Full configuration skeleton, with every option and its default
class: DomLinkExtractor
charset: string
contentTypeMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
extractSelectors:
- string
fieldMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
ignoreLinkData: false
ignoreNofollow: false
linkSelectors:
- extract: string
selector: string
noExtractSelectors:
- string
parser: string
restrictions:
- fieldMatcher: {}
valueMatcher: {}
schemes:
- string

Propertiesโ€‹

PropertyTypeRequiredDefault
charsetstringNo-
contentTypeMatcherTextMatcherNoTextMatcher
extractSelectorsstring[]No-
fieldMatcherTextMatcherNoTextMatcher
ignoreLinkDatabooleanNofalse
ignoreNofollowbooleanNofalse
linkSelectorsLinkSelector[]No[LinkSelector, LinkSelector, LinkSelector, LinkSelector]
noExtractSelectorsstring[]No-
parserstringNohtml
restrictionsPropertyMatcher[]No-
schemesstring[]No[http, https, ftp]

Property Detailsโ€‹

charsetโ€‹

The character encoding to use when reading or writing the document.

contentTypeMatcherโ€‹

Restricts processing to documents whose content type matches the specified pattern. When not set, the handler applies to all content types.

extractSelectorsโ€‹

CSS/jQuery-style selectors identifying portions of a document to be included for link extraction. Only links within the matched elements are considered by the link selectors.

fieldMatcherโ€‹

Matches document fields based on specified patterns and methods. Use this to restrict the handler to operate only on fields whose names satisfy the matcher criteria.

ignoreLinkDataโ€‹

When enabled, extra data attributes on links (such as data-* attributes) are ignored during link extraction.

ignoreNofollowโ€‹

When enabled, links marked with rel="nofollow" are followed and extracted anyway, ignoring the nofollow directive.

linkSelectorsโ€‹

CSS/jQuery-style selectors paired with extraction expressions that identify which elements to scan and what data to extract as a URL (e.g., attr(href) to extract an attribute value, or text for the element's text content). Defaults include selectors for a[href], [src], link[href], and meta[http-equiv='refresh'].

noExtractSelectorsโ€‹

CSS/jQuery-style selectors identifying portions of a document to be excluded from link extraction. Link selectors are not applied to elements matching these selectors.

parserโ€‹

Specifies whether to use the HTML or XML parser when reading document content into a DOM tree.

restrictionsโ€‹

Defines filter conditions that restrict which documents this committer processes. Documents not matching the restrictions are ignored by this committer.

schemesโ€‹

A list of URL schemes (e.g., http, https, ftp) that are accepted or filtered.