WWW::SearchResult - class for results returned from WWW::Search
require WWW::Search; require WWW::SearchResult; $search = new WWW::Search; $search->native_query(WWW::Search::escape_query($query)); # Get first result: $result = $search->next_result();
A framework for returning the results of WWW::Search.
WWW::Search
The particular fields returned in a result are backend- (search engine-) dependent. However, all search engines are required to return a url and title. (This list may grow in the future.)
To create a new WWW::SearchResult, call
$result = new WWW::SearchResult();
Returns the primary URL. Note that there may be a list of urls, see also methods urls and add_url. Nothing special is guaranteed about the primary URL other than that it is the first one returned by the back end.
urls
add_url
Every result is required to have at least one URL.
Add a URL to the list.
Return a reference to the list of urls. There is also a primary URL (url).
url
Add a URL to the related_url list.
Return a reference to the list of related urls.
Add a title to the list or related titles.
Return a reference to the list of related titles.
Set or get attributes of the result.
None of these attributes is guaranteed to be provided by a given backend. If an attribute is not provided its method will return undef.
undef
Typical contents of these attributes:
The title of the hit result (typically that provided by the 'TITLE' HTML tag).
A brief description of the result, as provided (or not) by the search engine. Often the first few sentences of the document.
Source is either the base url for this result (as listed on the search engine's results page) or another copy of the full url path of the result. It might also indicate the source site address where the resource was found, for example, 'http://www.cnn.com' if the search result page said "found at CNN.com".
This value is backend-specific; in fact very few backends set this value.
A backend specific, numeric score of the search result. The exact range of scores is search-engine specific. Usually larger scores are better, but this is no longer required. See normalized_score for a backend independent score.
This is intended to be a backend-independent score of the search result. The range of this score is between 0 and 1000. Higher values indicate better quality results.
This is not really implemented since no one has created an backend-independent ranking algorithm.
When the result was last changed. Typically this is the modification time of the destination web page.
When the search engine indexed the result.
The approximate size of the result, in bytes. This is only an approximation because search backends often report the size as "18.4K"; the best we can do with that number is return it as the value of 18.4 * 1024.
The raw HTML for the entire result. Raw should be exactly the raw HTML for one entry. It should not include list or table setup commands (like ul or table tags), but it may include list item or table data commands (like li, tr, or td). Whether raw contains a list entry, table row, br-separated lines, or plain text is search-engine dependent. In fact, many backends do not even return it at all.
Convert the search result to a human-readable form, decorated with HTML for pretty-printing.
More attributes of the result. Backend-specific.
WWW::SearchResult was written by John Heidemann. WWW::SearchResult is maintained by Martin Thurn.
To install WWW::Search, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Search
CPAN shell
perl -MCPAN -e shell install WWW::Search
For more information on module installation, please visit the detailed CPAN module installation guide.