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.
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.
Elements of the Template Testing tab:
- Project selection
- Template launch
- Adding a new project
Pre-installed projects cannot be saved, to save changes, you need to add a new project.
- Project deletion
- Project saving
- Formatting the JSON document
- Diagnostics of the template execution speed
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.
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.
Function code:
Tools.prototype.removeHtmlTags = function(string) {
return string.replace(/<[^>]*>/g, '');
}
Result format:
[%
FOREACH i IN serp;
tools.js.removeHtmlTags(i.snippet) _ "\n";
END
%]
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.
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.