Visual Field Mapping (Default)
Every task opens its extraction editor in Visual mode by default. Instead of manually writing JavaScript parsers, you define the fields and repeating groups you want to capture and target elements directly on the page. Figranium automatically generates and maintains the underlying execution script. Visual mode is ideal when:- Capturing named fields (e.g., title, price, author, URLs, element visibility) from a target page.
- Extracting repeating structured lists (e.g., product cards, search results, table rows).
- Building field mappings visually by picking elements directly in the Headful Browser.
- Avoiding custom JavaScript boilerplate for common web scraping tasks.
Field Configuration
In Visual mode, click Add Field in the Extraction Script block on the canvas or the Extraction tab in Task Settings. Each field supports six configuration parameters:Supported Attribute Types
Figranium provides seven specialized attribute extraction types:- Text (
text): Reads and trims text content (el.textContent.trim()). - HTML (
html): Extracts inner HTML (el.innerHTML). - Input Value (
value): Readsel.valuefor form elements (inputs, textareas, selects), falling back toel.textContent.trim()for non-form elements. - Attribute (
attr): Reads any explicit DOM attribute viael.getAttribute(attrName). - Element Exists (
exists): Evaluates whether a matching element exists in the DOM (document.querySelector(selector) !== null). Returns a booleantrueorfalse. - Image URL (
image): Resolves absolute image URLs from<img>elements or CSS background images. - Link URL (
link): Resolves absolute link URLs from anchors or clickable elements.
Advanced Media Extraction Types
Image URL Extraction (image)
Extracting image URLs from modern websites requires handling lazy loading, responsive srcset definitions, and CSS background images. When an attribute type is set to Image URL, Figranium executes an inline resolver that:
- Checks
el.currentSrc,el.src,data-src,data-lazy-src, ordata-originalattributes. - Inspects
srcsetattributes, parsing candidate URLs and returning the highest-density candidate. - Fallbacks to computed CSS background images (
getComputedStyle(el).backgroundImage) by extractingurl(...)declarations. - Resolves relative paths against the current page context (
location.href) to return a fully qualified absolute URL.
Link URL Extraction (link)
When set to Link URL, Figranium checks href, src, or data-href attributes on the matched element and converts relative paths into canonical absolute URLs using the browser’s location.href.
Repeating Groups (extractionGroups)
Web pages frequently contain repeating structures such as product listings, search result cards, tabular rows, or comment feeds. Figranium supports Repeating Groups to extract nested, structured array data without requiring manual loops.
How Repeating Groups Work
- Container Selector: Defines the parent repeating element on the page (e.g.,
.product-card,table.results > tr). - Sub-Fields: Defines individual fields (e.g.,
title,price,image_url) scoped to each container instance. - Relative Scope: Each sub-field selector is executed relative to its parent container element (
container.querySelector(...)).
Data Structure Example
Extracting a repeating group namedproducts with container selector .product-card yields an array of structured objects:
Under the Hood: Script Generation
When running in Visual mode, Figranium translates field definitions and repeating groups into an optimized JavaScript extraction function executed via Playwright’spage.evaluate().
Generated Script Example
For a task configured with top-level fields (title, banner_image, is_sale) and a repeating group (items), Figranium generates code equivalent to:
Picking Selectors with Headful Inspector
Next to selector inputs for both individual fields and repeating group containers is a target icon that launches the Headful Browser element inspector.- Click the target icon next to any field or group container selector.
- Click any element on the live browser canvas.
- Figranium inspects the element hierarchy and generates robust CSS selectors.
- A list of candidate selectors is displayed, allowing single-click substitution.
Extraction scripts run using native browser methods (
document.querySelector), which do not support Playwright-specific pseudo-selectors like :has-text(...). Figranium automatically filters out incompatible pseudo-selectors from inspector candidate lists when configuring visual extraction fields.Switching to JavaScript Mode
The mode toggle at the top of the Extraction editor allows switching between Visual and JavaScript modes.- Visual Mode: Manages field mappings and repeating groups visually.
- JavaScript Mode: Exposes the full JavaScript editor for writing custom extraction logic, data transformation pipelines, or post-processing algorithms.
Extraction Script Environment (JavaScript Mode)
In JavaScript mode, the code executes inside the browser page context and has access to:document: The DOM of the active page.$$data.html(): A utility returning the cleaned page HTML string.variables: Task runtime variables accessible as a key-value object.
Example: Custom JavaScript Extraction
DOM Cleaning and Shadow DOM
Before extraction runs, Figranium optimizes page HTML to reduce payload size and eliminate noise.Stripped Elements
The following tags are removed during cleaning:script, style, link, meta, noscript, svg, canvas, iframe, object, embed, applet, param, source, track
Preserved Attributes
- Identification:
id,class,name - Links & Media:
href,src,alt,title,value,placeholder,content,datetime - Accessibility & Forms:
aria-label,type,for,action,method,selected,checked,disabled - Tables:
colspan,rowspan,scope - Custom Data Attributes: All
data-*attributes (e.g.,data-id,data-sku,data-price)
Shadow DOM Support
If a web page utilizes open Shadow DOM trees (common in Web Components), Figranium serializes shadow roots into<template data-shadowroot="open"> elements inside cleaned HTML. Shadow DOM inclusion can be toggled on or off in Task Settings.
AI Extraction Script Generation
Figranium includes AI assistance to write custom extraction scripts from natural language prompts. For detailed instructions on model settings and prompt guidelines, refer to the AI Extraction Script Generation guide.Output Formats and Dynamic Content
Handling Dynamic Content
If a page loads data asynchronously via AJAX or client-side rendering, includewait or wait_selector action blocks prior to the extraction step to ensure all DOM elements are present before extraction runs.
CSV Output Formatting
When setting the task output format to CSV:- Ensure the extraction result returns an Array of Objects (or an object containing a single array property).
- Object keys in the array elements automatically become CSV header columns.
- Values are formatted, quoted, and escaped automatically according to RFC 4180 standards.
Single Repeating Group Unwrapping
When the extraction result is an object with a single key whose value is an array of objects (the shape produced by a lone repeating group), Figranium unwraps that array before serialization. Each group item becomes its own CSV row instead of a single row containing a stringified array in one cell. For example, an extraction that returns:Extraction Script Generation
Generate custom extraction scripts with AI assistance.
JavaScript Execution
Write custom mid-flow logic and data transformation.
CSV Processing
Parse and iterate over CSV data in your tasks.
Selectors
Learn how to target elements for extraction and actions.