Tools in the Templаte toolkit
Description(top)In template processing system Template Toolkit the global variable $tools is available, which stores in itself a tool kit available in any template.
$tools.error - contains a description of errors that may occur during executing any of tools.
$tools.ua- changeover of User agent(top)This tool is intended for substitution of User agent in parsers which use it (for example Net::HTTP).
- $tools.ua.list - contains the User agent list
- $tools.ua.random() - a method, brings accidental User agent out of the list
$tools.query - adding of requests(top)This tool allows to add requests to already existing directly during work of task, creating them on a basis already parsed results. It can be used as analog of the Parse to level function in those parsers where it isn't realized.
- [% tools.query.add (query, maxLevel) %] - adds single request
- [% tools.query.addAll (array, item, maxLevel) %] - adds an array of requests
$tools.parseJSON - parsing JSON structures(top)This tool allows you to deserialize the data in JSON format to the variables, available in the template engine.
- [% tools.parseJSON(data) %] - launches the analysis of structure
$tools.base64.* - ability to encode and decode base64(top)This tool allows you to encode the text in base64 and decode back. Example:
$tools.data - built-in parameter directory(top)This tool contains a lot of pre-installed information - languages, regions, domains for Google and Yandex search engines. Complete list of elements:
each of which is an array or hash data, you can see the contents like this:
[% tools.data.GoogleDomains.json() %]