Merge Dynamic Parser

Merge Dynamic Parsers

The "Merge Dynamics" feature in Nimble's Web API provides users with the ability to seamlessly integrate Nimble's AI-powered parsing with custom parsing logic into a single, unified response.

This feature is particularly useful for advanced use cases where the out-of-the-box AI parsing might need further refinement, customization, or additional context provided by user-defined parsing rules. By combining both AI and custom parsing, users can achieve a more accurate and tailored data extraction process.

Benefits

  • Enhanced Flexibility: Users can extend and customize the default AI parsing to meet specific data requirements, ensuring that all necessary information is captured in one go.

  • Unified Output: The merging of AI and custom parsing ensures that the final output is consistent, organized, and ready for further processing or analysis.

  • Improved Accuracy: By adding custom parsing, users can refine the data extraction process to capture niche or specialized information that might be missed by general AI parsing.

Request Options

ParameterRequiredDescription

parser

Required as true (default = false)

Enum: true | false True - the page's content will be parsed and returned in a JSON format. False - Response will include page headers and raw data (without parsing).

parse_options

Required to enable merge dynamic feature

Object | For advanced parsing options such as merge_dynamic

parse_options.merge_dynamic

Required as true (default = false)

Bool | when set to true, the custom parser results would merge into the AI parsing results under new entity named DynamicEntity

parser

Required

Object | The custom parser template to be merge

Example Request

curl -X POST 'https://api.webit.live/api/v1/realtime/web' \
--header 'Authorization: Basic <credential string>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url": "https://www.yelp.com/biz/7-eleven-pembroke-pines-7",
    "country": "US",
    "parse": true,
    "render": true,
    "parse_options": {
        "merge_dynamic": true
    },
    "parser": {
        "YelpBusiness": {
            "selectors": ["html"],
            "type": "object-list",
            "fields": {
                "business_id": {
                    "selectors": [
                        "meta[name='yelp-biz-id']"
                    ],
                    "extractor": "[content]"
                }
            }
        }
    }
}'

Example Response

  • The merged results of the custom parser could be found under DynamicEntity entity

{
    ...
    "parsing":
    {
        "entities":
        {
            "BreadcrumbList": [...],
            "DynamicEntity":
            [
                {
                    "YelpBusiness":
                    [
                        {
                            "business_id": "Z6VUesj0B7wJX3_yqKKPgA"
                        }
                    ],
                    "entity_type": "Dynamic"
                }
            ],
            "ItemList": [...],
            "LocalBusiness": [...]
        },
        "total_entities_count": 6,
        "entities_count":
        {
            "BreadcrumbList": 3,
            "DynamicEntity": 1,
            "ItemList": 1,
            "LocalBusiness": 1
        },
        "metrics":
        {}
    }
}

Last updated