Documentation has been updated: see help center and changelog in one place.

Parsing function examples

Practical examples of Custom Parser functions for HTML processing, string manipulation, mathematical operations, and common parsing tasks.

HTML processing

element_text

Sample HTML

<!DOCTYPE html>
<html>
<body>
    <div id="product">
        <div id="product-description">This is a nice product</div>
        <div id="product-price">    12  3


        </div>
    </div>
</body>
</html>

Extract text from HTML element and strip whitespaces

{
    "price": {
        "_fns": [
            {
                "_fn": "xpath_one",
                "_args": [".//*[@id='product-price']"]
            },
            {
                "_fn": "element_text"
            }
        ]
    }
}

Given a string value as an input, do nothing

xpath

Sample HTML

Get all description items

Get the first description item

Check if the description section element exists

Get price as a number

Multiple expressions to fallback to in case preceding expression fails

XPath | operator to match with multiple expressions

xpath_one

Sample HTML

Return the first match

Using XSLT functions

String manipulation

amount_from_string

Sample HTML

Extract amount from string

amount_range_from_string

Sample HTML

Extract all amounts from string

join

Sample HTML

Join an array of strings into a single string

regex_find_all

Sample HTML

Find all matches between two characters

Sample HTML

Return description between two characters

regex_substring

Sample HTML

Replace a part of text with specified value

Common functions

convert_to_*

Sample HTML

Get the count of price variants

Get the count of price variants in a multi-dimensional array

Sample HTML:

select_nth

Sample HTML

Select the first description item from the array

Select the last description item from the array

Math functions

average

Sample HTML

Find the average of all listed prices

max

Sample HTML

Find the max of all listed prices

min

Sample HTML

Find the average of all listed prices

product

Sample HTML

Get the count of different product variants

Last updated

Was this helpful?