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

NAME

WWW::Scraper::Response - Response class of generic scrapes.

SYNOPSIS

    use WWW::Scraper('engineName');
    #
    my $scraper = new WWW::Scraper('engineName');
    my $response = $scraper->Response();
    #
    my $field = $response->$fieldName();
    # or
    my $field = $scraper->Response->$fieldName();
    #
    # or, specify your own Response class.
    my $scraper = new WWW::Scraper('engineName', 'responseClass');
    my $field = $scraper->Response->$fieldName();

DESCRIPTION

Scraper automatically generates a "Response" class for each scraper engine. It does this by parsing the "scraperFrame" to identify all the field names fetched by the scraper. It defines a get/set method for each of these fields, each named the same as the field name found in the "scraperFrame".

Optionally, you may write your own Response class and declare that as the Response class for your queries. This is useful for defining a common Response class to a set of scraper engines (all auction sites, for instance). See WWW::Scraper::Response::Auction for an example of this type of Response class.

METHODS

$fieldName

As mentioned, Response will automatically define get/set methods for each of the fields in the "scraperFrame". For instance, for a field named "postDate", you can get the field value with

    $response->postDate();

You may also set the value of the postDate, but that would be kind of silly, wouldn't it?

GetFieldNames

A reference to a hash is returned listing all the field names in this response. The keys of the hash are the field names, while the values are 1, 2, or 3. A value of 1 means the value comes from the result page; 2 means the value comes from the detail page; 3 means the value is in both pages.

SkipDetailPage

A well-constructed Response class (as Scraper auto-generates) implements a lazy-access method for each of the fields that come from the detail page. This means the detail page is fetched only if you ask for that field value. The SkipDetailPage() method controls whether the detail page will be fetched or not. If you set it to 1, then the detail page is never fetched (detail dependent fields return undef). Set to 2 to read the detail page on demand. Set to 3 to read the detail page for fields that are only on the detail page, and don't fetch the detail page, but return the results page value, for fields that appear on both pages.

SkipDetailPage defaults to 2.

ScrapeDetailPage

Forces the detail page to be read and scraped right now.

GetFieldValues

Returns all field values of the response in a hash table (by reference). Like GetFieldNames(), the keys are the field names, but in this case the values are the field values of each field.

GetFieldTitles

Returns a reference to a hash table containing titles for each field (which might be different than the field names).

AUTHOR

WWW::Scraper::Response::Scraper is written and maintained by Glenn Wood, http://search.cpan.org/search?mode=author&query=GLENNWOOD.

COPYRIGHT

Copyright (c) 2001 Glenn Wood All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.