The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::SearchResult - class for results returned from WWW::Search

SYNOPSIS

    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();

DESCRIPTION

A framework for returning the results of WWW::Search.

SEE ALSO

WWW::Search

REQUIRED RESULTS

The particular fields returned in a result are back-end (search-engine) dependent. However, all search engines are required to return a url and title. (This list may grow in the future.)

METHODS AND FUNCTIONS

new

To create a new WWW::SearchResult, call $search = new WWW::SearchResult();

url

Return 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.

Every result is required to have at least one URL.

urls

Return a reference to an array of urls. There is also a primary URL (url). See also add_url.

add_url

Add a URL to the list.

Analgous to urls, these functions provide lists of related URLs and their titles. These point to things the search engine thinks you might want (for example, see Infoseek).

title, description, score, change_date, index_date, size, raw

Set or get attributes of the result.

None of these attributes is guaranteed to be provided by a given back-end. If an attribute is not provided its method will return undef.

Typical contents of these attributes:

    The title of the hit result (typically that provided by the 'TITLE' HTML tag).

    description

    A brief description of the result, as provided (or not) by the search engine. Often the first few sentences of the document.

    score

    A back-end 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 back-end independent score.

    normalized_score

    A back-end independent score of the search result. The range of this score is between 0 and 1000. Higher values indicate better quality results.

    change_date

    When the result was last changed.

    index_date

    When the search engine indexed the result.

    size

    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.

    raw

    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 the ul tag), but it may include list or table item commands (like li). Whether raw returns a list entries, table entries, or just br or unformatted HTML is search-engine dependent. In fact, many backends do not even return it at all.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 163:

=over should be: '=over' or '=over positive_number'

You can't have =items (as at line 169) unless the first thing after the =over is an =item