1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Join our Telegram chat: https://t.me/a_parser_en
    Dismiss Notice

Formatting of results

Aug 24, 2017

  • In A-Parser is applied to formatting of results Template Toolkit, that allows to save easily results of parsing in different formats:
    • In text files by list: one result for the line, through a separator, in arbitrary format
    • In the CSV files with possibility of further import to Excel, Google Docs, etc.
    • In XML, JSON and other data storage formats
    • In HTML on the fly generating pages
    • In the SQL dumpings format for direct import to database
    • In a binary format for saving of images (jpg, png, gif, ...), documents (pdf, docx, ...), executable files and archives (exe, dmg, zip, ...) and any other data types
    Recommended to study article of documentation Представление результатов и базовые принципы форматирования and with a detailed manual on Template Toolkit

    Editing format of result(top)

    Result format - allows to format results to the necessary look using templates, the request results is applied to each combination

    • General format of result is set in the field Result format
    • Result format for each parser separately can be set in settings of a parser in Result format
    A-Parser supports work with several parsers in one task, in general format of results it is necessary to specify from what parser output result
    • $p1 - results from the first parser (SE::Google SE::Google on a screenshot), $p2 - results from the second parser (SE::Bing SE::Bing on a screenshot)
    • Sequence number of a parser is displayed to the left of a parser choice field
    • of $p1.preset and $p2.preset implies that it is necessary to take value format of result from settings of the appropriate parsers
    • In this example $p1.preset can replace with $p1.serp.format ('$link\n') that will have identical effect, thus the result format from settings won't be used any more

    Result format can be specified in a convenient multiline editor having clicked the appropriate icon in the field of editing:
    In the general format of results the following variable is available :
    • $query - request after formatting
    • $query.* - all variables relating to request are described in article Шаблоны в запросах
    • $p1, $p2, ... - variables for access to results of parsing for each parser separately
    • of $p1.query, $p2.query... - requests after formatting taking into account a request format each parser specified in settings

    Prepend and append text(top)

    For each result file, a separate Append/Prepend text:
    • For formation of CSV cap of the file
    • For beginning and finite tags of the XML file
    • For a header, a cap and a footer of HTML files
    • For any other options of application
    To activate the present possibility it is necessary to click the button [​IMG] in the lower part of theTask editor


    In the initial and finite text use of a shablonizator of Template Toolkit, available variables is supported:
    These variables are available only when saving each request in the separate file

    Format your results file name(top)

    A-Parser allows to use templates also in names of result files, that allows to create automatically files and folders on the basis of current date, on sequence number of request, on the request and in any other format
    In the field File name are supported the following variables:
    • All variables available to the General format of result
    • $queriesfile - path and file name with queries, if requests are specified through the form that will contain queries_from_text.txt
    • $datefile - the object date plug-in of Template Toolkit which is set up on a format date %b-%d _%H-%M-%S, when formatting gives out the current time and date in look May-08_20-08-38, change format is possible in Advansed settings
    By default the file name is created on a date and time at the time of start of the task

    Complex example

    • Reports folder will be created
    • Subfolder with file name of requests Will be created
    • In subfolder will be created so many files, how many requests is used in task, as file name will be used the request with extension .txt
    Variable $query is written in a format ${query} to prevent interpolation of extension .txt as parts of a variable, is more detailed in documentation on Template Toolkit