Skip to main content

Tools

This section of the menu contains auxiliary and service tools of A-Parser.

Templates Testing

For quick verification of templates in A-Parser, there is a built-in Templates Testing tool, which contains preset results for all scrapers for test queries, allowing you to perform the formatting template without actual scraping. Here you can test templates for subsequent use in presets.

Templates testing

In the dropdown menu Project you can select a ready-made results structure for one of the built-in scrapers, or you can insert your own json into the JSON field. On the right, in the Template field, you write the template being tested, and at the bottom, in the Result field, after pressing the Start button, you can see the result of the template execution.

In the template testing, all the rules of the templating engine are fully functional, so you can also test complex templates using built-in templating tools.

Templates testing - elements

Elements of the Templates Testing tab:

Adding a new project


Deleting a project


Saving a project


Formatting a JSON document


Template execution speed diagnostics

Preset projects cannot be saved, to save changes you need to add a new project.

Templates testing is available for each scraper separately, for this you need to select a preset project.

The results are presented in JSON format, which allows you to make changes to the source data if necessary.

After changing the template, you need to apply it - the Start button in the upper right corner.

If the template is composed incorrectly, a detailed error will appear in the Result field:

Example of error output in a template

JavaScript Editor

JavaScript Editor

On this tab, you manage (create/edit/delete) functions used in tools.js.

Let's look at the following function, which is available by default in the JavaScript Editor:

Tools.prototype.sum = function(a, b) {
// Тело функции (Здесь могут быть дополнительные вычисления)
return a + b;
}

sum - the name of the function, by which it will be accessible through $tools.js.sum

a, b - the function's arguments (optional)

a + b - the function's returned result

Example of Creating a Function

Example of creating a function to remove HTML tags and testing its work in the Template Testing tab.

Example of creating an html tag cleaning function

Function code:

Tools.prototype.removeHtmlTags = function(string) {
return string.replace(/<[^>]*>/g, '');
}

Result format:

[% FOREACH i IN serp;
tools.js.removeHtmlTags(i.snippet) _ "\n";
END %]
The result of the function removeHtmlTags

Updating A-Parser

Update A-Parser

On this tab, you can update A-Parser to the latest version using the interface.

Service

This is a service tab, which provides access to:

  • Debugging and diagnostics of A-Parser's operation
  • Restarting and terminating A-Parser
  • Translation editor

In most cases, these tools are used only for the development of A-Parser or for diagnosing problems and are not needed by users for operation.

Regex Builder

Regex Builder

The regex builder is used for quickly composing simple regular expressions. Its full description is available here.