-
Join our Telegram chat: https://t.me/a_parser_enDismiss Notice
Representation of results
-
Contents
A-Parser was created for parsing of information of any kinds, were for this purpose introduced 2 types of results :
- Simple results (Flat)
- Arrays of results (Array)
SE::Google, screenshot of search result:
Simple results(top)
Simple results - when corresponds to one request one result, examples:
- Amount of results on request ($totalcount)
- Whether the request is a misprint ($misspell, on a screenshot isn't displayed)
- Value of PageRank ($pr) in a parser
SE::Google::pR
- Value of TIC ($tic) in a parcer
SE::Yandex::TIC
- Number of the referring domains ($domains), IP addresses ($ips), backlinks ($backlinks), etc. in a parser
Rank::MajesticSEO
Arrays of results(top)
Arrays of results - when corresponds to one request the list of results, each element of list in turn may contain some nested elements. Let us consider on example of search output of Google - it is provided in a parser by an array $serp, for descriptive reasons we will use the table, in which write the first 5 results of output:
Each line item of output writers in array with 3 nested elements - the link ($link), an anchor ($anchor), a snippet ($snippet)
Other example - the list of the related keywords, which remains in array $related:
Apparently in this array only one nested element - keyword ($key)
Numbering of elements in arrays begins with 0, an example of access to separate array cells:
- $serp.0.link - the first link from output
- $serp.3.anchor - the fourth anchor from output
- $related.0.key - first related keyword
Viewing of possible results(top)
Each parser has the result set, view the list of available results possible to having guided at a parcer the pointer, in the tooltip balloon will be displayed the list of simple results and arrays, with the list of nested elements:Yellow are marked results which is the general for all parsers :
- $query - the request transferred to a parser after formatting
- $query.orig - original request (in that look as it was in the file or in a field of request)
- $query.first - the first request when using options of nested parsing (Parse all results or Parse to level)
- $info.success - information about success of parsing of this request
- $info.retries - number of the used retries for this request
- $info.stats - statistics of work a parcer for this request
- $pages.$i.data - an array with the raw responses from the server for possibility of free extraction of additional information
SE::Google:
- $related.$i.key - an array with the list of the related keywords
- $ads with elements $link, $anchor and $snippet - an array with the list of ads
$serp - with $link elements , the $anchor and the $snippet - an array with the main output of the searcher
Also available variable $response, which allows you get any query variables, including all previous redirections.
Basic principles of formatting(top)
After the parser collected data in simple results and arrays, they need to be displayed (or save to the file) in the necessary format. For convenience and functionality in A-Parser used Template Toolkit. We will investigate often used constructions, for this purpose we will use the tool Template tester. We will select the project for a parserSE::Google:
On a screenshot 3 fields are provided:
- JSON - internal data representation in a parcer
- Template - a template on which there is a formatting of result
- Result - directly the transformed data on the specified template, in such look result will be written in the file
Select the basic rules:
- Plain text is output in result as is, without changes
- For output of simple results it is necessary in the right place to output the variable, containing the necessary result with $ prefix
- For formatting of arrays is used format method, about it is below
- \n is responsible for line break
Formatting of arrays(top)
Formatting of arrays, we will investigate construction:Code:$serp.format('$link $anchor\n$snippet\n\n')
The output of variable values in JSON(top)
The output of variable values in JSON:
Code:$results.json
Examples
Output of competition on request (amount of results on request) for all parsers of search engines (SE::Google,
SE::Yandex...):
Code:$query: $totalcount\n
Code:test: 3910000000 viagra: 278000000 окна пвх: 3220000 ...
Output of links from output of search engines:Code:$serp.format('$link\n')
Code:http://www.speedtest.net/ http://www.speakeasy.net/speedtest/ http://en.wikipedia.org/wiki/Test_cricket http://www.humanmetrics.com/cgi-win/jtypes2.asp http://html5test.com/ http://test-ipv6.com/ ...
Output of suggests from search engines:Code:$results.format('$suggest\n')
Code:тестовый сервер танки онлайн тесты гиа по русскому языку тесто для блинов рецепт тестикула тесто для пиццы на молоке ...
Output of statistics on a keyword using a parserSE::Yandex::WordStat:
Code:тест - 11233054, updated: 30.04.2014 keywords: тест: 11233054 тест класс: 1319919 тест драйв: 1051495 тесты онлайн: 827044 тесто +для теста: 729279 тесты 2014: 592935 ... additional keywords: mail: 20449501 анекдоты: 1813239 анекдоты +из россии: 22754 анекдоты приколы: 9122 приколы: 4677777 test: 872855 ...