Skip to main content

Tools

In this menu section, auxiliary and service tools of A-Parser are collected.

Template Testing​

To quickly check templates in A-Parser, there is a built-in Template Testing tool. It contains pre-installed results for all scrapers for test queries, which allows you to perform template formatting without actual parsing. Here you can test templates for subsequent use in presets.

img

In the Project drop-down menu, 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, the tested template is written, and at the bottom, in the Result field, after clicking the Run button, you can see the result of executing the template.

All rules of the template engine work in full in template testing, so you can also test complex templates using built-in template engine tools.

img

Elements of the Template Testing tab:

  • Project selection img
  • Template launch img
  • Adding a new project img

Pre-installed projects cannot be saved, to save changes, you need to add a new project.

  • Project deletion img
  • Project saving img
  • Formatting the JSON document img
  • Diagnostics of the template execution speed img

Template testing is available for each scraper separately, for this, you need to select a pre-installed project.

The results are presented in JSON format, which allows making changes to the source data if necessary (more about JSON on WikiPedia).

After changing the template, it must be applied - the Run button in the upper right corner.

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

img

JavaScript Editor​

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

The code of each function must have the form:

Tools.prototype.NAME = function(a, b, ...) {
// ΠΊΠΎΠ΄ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ
return RESULT;
}

where NAME is the name of the function, by which it will be available through tools.js.NAME; a, b, ... - function arguments (optional); RESULT - the returned result.

Function Creation Example​

An example of creating a function to remove HTML tags and testing its operation in the Template Testing tab.

an example of creating a function to remove html tags

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 to remove html tags

Updating A-Parser​

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

After clicking the Update button, the A-Parser distribution will be compiled and downloaded, after which you will be prompted to select which files need to be updated.

caution

Usually, it is enough to update only the executable file (it is marked by default). Other files are better to update only if necessary, after making a backup copy.

After a successful update, A-Parser will be restarted.

Service​

This is a service tab that provides:

  • debugging and diagnostics of A-Parser operation
  • restarting and stopping A-Parser
  • translation editor

In most cases, these tools are used only for A-Parser development or problem diagnostics and are not needed for regular users.

Regular Expression Constructor​

The regular expression constructor is used to quickly create simple regular expressions. Its full description is available here.