Precise data extraction with powerful parser syntax
Parsing Schema gives you full control over data extraction using a comprehensive parser syntax. Define exact data structures for predictable, low-cost extraction from HTML, JSON, XML, and network captures.Parsers are the complete recipe for processing web content into structured data. They combine:
Must be set to true to enable parsing. This tells Nimble you want to extract structured data using the parser you define.When disabled, you’ll just get raw HTML without structured extraction.
Your custom extraction recipe that defines exactly what data to pull from the page and how to structure it.Parser structure:Each field in your parser is a key-value pair where:
Key - The name of the field in your output (like "product_name" or "price")
Value - An object that describes how to extract that field
Every parser needs:
type - What kind of parser to use
terminal - Extract a single value (like one price)
terminal_list - Extract multiple values (like a list of image URLs)
schema - Extract a nested object (like product details)
schema_list - Extract a list of objects (like multiple products)
or - Try multiple strategies, use first one that works
and - Combine multiple extraction strategies
const - Return a fixed value
selector - How to find the element on the page
Use CSS selectors (.product-name, #price, etc.)
Or XPath, JSON paths for other data types
extractor - What data to grab from the element
text - The text content
attr - An attribute value (like href or src)
json - Parse JSON data
raw - The raw HTML
post_processor (optional) - Transform the data
Convert to number, format dates, clean text, etc.
Think of it as: “Find THIS element, grab THIS data from it, and format it like THIS”
terminal - Returns a single terminal/literal as output.
terminal_list - Returns a list of literals instead of a single literal.
schema - Returns a dictionary/JSON according to its field parsers.
schema_list - Returns a list of dictionaries/JSONs instead of a single dictionary/JSON.
or - Tries a sequence of parsers and returns the result of the first parser that returns a non-null value
and - Runs a sequence of schema parsers and merges their results into a single output. All parsers execute on the same input, and results are combined (first non-null value wins for overlapping keys).
const - Always returns its value regardless of the input. Useful for adding static data to your output.
Runs a sequence of schema parsers and merges their results into a single output. All parsers execute on the same input, and results are combined (first non-null value wins for overlapping keys).
xpath - Enables powerful element selection using XPath expressions. Particularly useful for XML documents like RSS feeds and sitemaps.
json - Extracts JSON elements from the page. All subsequent selectors and extractors receive JSON instead of HTML.
sequence - Combines multiple selectors in sequence. Useful for chaining different selector types.
parent - Traverses up the DOM tree (for HTML) or context hierarchy (for JSON). Useful when you need to select a parent element after finding a specific child.
root - Returns the original page (document). Often used with JSON selector to access fields like network_capture, url, or html.
//element - Select all elements with the given name - /root/child -
Select child elements of root - //element[@attr='value'] - Select by
attribute value - //element[position()=1] - Select first element -
//*[local-name()='element'] - Select ignoring namespaces
The coercion_filter field provides advanced control when dealing with multiple JSON objects. It uses JSONPath expressions to filter specific JSON objects.
{ "type": "json", "coercion_filter": "$[1]", // Get the second JSON object "path": "nested.keys"}
Extractors specify what data to extract from the selected element. Supported extractors:
text - Extracts the text content of the element. Works with both HTML (CSS selectors) and XML (XPath selectors).
strip (optional, boolean) - If it is set to false, leading and trailing whitespaces are preserved in the text. Default is true.
separator (optional, string) - Specifies a separator string to use when joining text from different child elements. When extracting text from nested HTML elements, this separator will be inserted between text from different elements. If not specified, text from different elements is concatenated without a separator.
attr - Extracts an attribute value from the element. Works with both HTML and XML elements. common attr:
href - Links
src - Images, scripts
data-* - Custom data attributes
class - CSS classes
id - Element IDs
json - Extracts JSON content using JSONPath.
raw - Extracts an element as-is without coercion. JSON stays as JSON, strings stay as strings. Useful for advanced parsing with complex JSON selectors.
If no extractor is specified, the raw extractor is used by default.
Extracts the text content of the element. This extractor works with both HTML elements (from CSS selectors) and XML elements (from XPath selectors).You can use strip=false to keep leading and trailing whitespace characters. The default is to remove them.
The text extractor supports both HTML elements (BeautifulSoup Tag) from CSS
selectors and XML elements (lxml Element) from XPath selectors. This allows
you to use the same extractor regardless of whether you’re parsing HTML or XML
documents.
This example demonstrates parsing a complete BBC news article about a three-legged cat, showing how to extract structured data from HTML using various parser types, selectors, and extractors.
terminal_list: Returns an array of values instead of a single value
Selector:article img selects all img elements within article
Extractor:attr with src gets the image source
Post-processor:url converts relative URLs to absolute (e.g., /news/... → https://www.bbc.com/news/...)
Show Parsing: paragraphs (list)
Extract all article paragraphs as an array of strings.HTML Structure:
<article> <div data-component="text-block" class="sc-18fde0d6-0 dlWCEZ"> <p class="sc-eb7bd5f6-0 fYAfXe"> A three-legged cat has captured a town's imagination... </p> <p class="sc-eb7bd5f6-0 fYAfXe"> The people of Daventry, Northamptonshire, love taking photographs... </p> <!-- more paragraphs --> </div></article>
{ "url": "https://www.bbc.com/news/articles/cervlxymly2o", "title": "Three-legged cat 'brings town together'", "date": "2024-07-29T00:00:00", "author": { "name": "Martin Heath", "organization": "BBC News, Northamptonshire" }, "images": [ "https://ichef.bbci.co.uk/news/480/cpsprodpb/2a87/live/321fae30-4c01-11ef-b2d2-cdb23d5d7c5b.jpg.webp", "https://ichef.bbci.co.uk/news/480/cpsprodpb/a8c2/live/904194b0-4c01-11ef-b2d2-cdb23d5d7c5b.jpg.webp", "https://ichef.bbci.co.uk/news/480/cpsprodpb/7579/live/9ecae4f0-4c01-11ef-aebc-6de4d31bf5cd.jpg.webp" ], "paragraphs": [ "A three-legged cat has captured a town's imagination with his appearances in shops and offices.", "The people of Daventry, Northamptonshire, love taking photographs of the 14-year-old feline and documenting his travels on social media.", "Funds have been raised to buy a street sign with his name on it, and souvenir Salem T-shirts could follow." ]}
This example demonstrates parsing structured data from embedded JSON-LD (Linked Data JSON) within an HTML page. Many websites embed JSON-LD in their HTML to help search engines understand their content - we can leverage this for easier, more reliable parsing.
What is LD+JSON? Linked Data JSON is a format for structuring data in a machine-readable way. It’s often embedded in webpages using <script type="application/ld+json"> tags to provide search engines with detailed information about products, articles, events, and more.
XPath provides a powerful query language for parsing XML documents like RSS feeds, sitemaps, product catalogs, and other structured XML data. Unlike CSS selectors designed for HTML, XPath is specifically built for XML navigation.
RSS feeds are a common XML format for syndicating content. Let’s parse a typical RSS feed structure.XML Structure:
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"> <channel> <title>Example RSS Feed</title> <link>https://example.com</link> <description>A sample RSS feed</description> <item> <title>Getting Started with XPath</title> <link>https://example.com/xpath-guide</link> <description>Learn how to use XPath for XML parsing</description> <pubDate>Mon, 01 Jan 2024 10:00:00 GMT</pubDate> </item> <item> <title>Advanced XML Techniques</title> <link>https://example.com/xml-advanced</link> <description>Deep dive into XML parsing strategies</description> <pubDate>Tue, 02 Jan 2024 14:30:00 GMT</pubDate> </item> </channel></rss>
Handling Namespaces:The local-name() function ignores XML namespaces. Instead of //*[name()='ns:url'] which requires namespace registration, use //*[local-name()='url'] to select elements by name alone.
Without local-name(): //ns:url (requires namespace prefix)
With local-name(): //*[local-name()='url'] (works regardless of namespace)
Use Relative XPath in Nested ParsersWhen working with nested schema parsers, use relative XPath expressions (starting with .//) to keep selectors scoped to the parent element. This makes parsers more maintainable and performant.
Namespace HandlingWhen parsing XML with namespaces (like sitemaps, Atom feeds), use local-name() to ignore namespaces unless you need to distinguish between elements with the same name in different namespaces.
Element-Only ResultsXPath selectors only return Element nodes. Use the text or attr extractors to get data from the selected elements. Don’t try to select text nodes directly with //title/text().
Combine with Post-ProcessorsUse post-processors to convert extracted text to appropriate data types:
Parsing Network API Calls from Target.com Product Page
Modern web applications often load data dynamically through API calls rather than embedding it directly in HTML. Nimble’s network capture feature records these API responses, allowing you to parse structured JSON data directly from backend endpoints - often cleaner and more reliable than parsing the rendered HTML.
What is Network Capture?Network capture records API calls made by the browser while loading a page. This gives you access to the raw JSON responses from backend services, which often contain more complete data than what’s visible in the HTML.
Show Complete Walkthrough
Target URL:https://www.target.com/p/A-87562588When you visit a Target product page, the browser makes an API call to /pdp_client_v1 that returns comprehensive product data in JSON format. Instead of parsing the complex HTML, we can extract this data directly from the captured API response.
JSONPath: Navigate to the formatted_current_price field
regex post-processor: Extract numeric value from formatted string “$399.00” → “399.00”
number post-processor: Convert string to actual number type: “399.00” → 399.00
sequence: Chain post-processors for multi-step transformation
Show Parsing: return_policy_best_guest (with JSONPath filtering)
The return policy is buried within an array of bullet points. We need to filter to find the specific bullet containing return information.API Response Structure:
{ "data": { "product": { "item": { "product_description": { "bullet_descriptions": [ "<B>Returns:</B> This item must be returned within 30 days...", "<B>Packaging:</B> Shows what's inside...", "<B>Warranty:</B> 1 Year Limited Warranty..." ] } } } }}
{ "title": "Apple Watch Series 9 GPS 45mm Midnight Aluminum Case with Midnight Sport Band - M/L", "image_url": "https://target.scene7.com/is/image/Target/GUEST_3ad473cc-8f21-44c8-85ca-b9a1dee1806c", "price": 399.0, "return_policy_best_guest": "This item must be returned within 30 days of the date it was purchased in store, shipped, delivered by a Shipt shopper, or made ready for pickup.", "children_product_titles": [ "Apple Watch Series 9 GPS 41mm Midnight Aluminum Case with Midnight Sport Band - S/M", "Apple Watch Series 9 GPS 41mm Midnight Aluminum Case with Midnight Sport Band - M/L", "Apple Watch Series 9 GPS 45mm Starlight Aluminum Case with Starlight Sport Band - S/M", "Apple Watch Series 9 GPS 45mm Starlight Aluminum Case with Starlight Sport Band - M/L" ]}
Important: You must set render: true and
render_options.capture_network_calls: true to enable network capture.
Without these settings, the network_capture field will not be available.