WWW::Baidu::Record - Record object representing an item in baidu.com's search results


WWW-Baidu documentation Contained in the WWW-Baidu distribution.

Index


Code Index:

NAME

Top

WWW::Baidu::Record - Record object representing an item in baidu.com's search results

VERSION

Top

This document describes version 0.06 of WWW::Baidu::Record, released Jan 21, 2007.

SYNOPSIS

Top

    # ... construct the WWW::Baidu object $baidu somehow earlier
    $record = $baidu->next;
    if ($record) {
        print "Found page titled ", $record->title;
        print " whose URL is ", $record->url;
        print " and the summary looks like ", $record->summary;
        print ". Its size is ", $record->size;
        print ". You can preview the cached version from ", $record->cached_url,
        print " if you've got a 404 error. :)";
    }

DESCRIPTION

Top

This class represent objects for the search results returned by Baidu.com.

CONSTRUCTIOR

Top

There's a constructor generated automatically by Class::Accessor, but usually you don't need to construct a WWW::Baidu::Record instance yourself.

Please always use the next method of WWW::Baidu object to get an object of this class.

PROPERTIES

Top

All the properties of this class are read-only and return strings in the GBK/GB2312 encoding. If you want UTF-8, use the Encode module to decode the strings yourself:

    use Encode 'decode';
    $utf8 = decode('GBK', $gbk);

$value = $obj->title

Returns the matched web page or document's page title.

$value = $obj->url

Returns the absolute URL for the matched web document.

$value = $obj->summary

A brief summary for the matched web document from Baidu.com

$value = $obj->size

Size info for the matched document. Note that it's not an number, instead it's in the form of '32K' or something like that.

$value = $obj->cached_url

Returns the url pointing to the cached version of the matched document on Baidu.com. Note that, for documents with types like DOC, PPT and XSL, there won't be a cached version. So this property always returns undef in these cases.

AUTHOR

Top

Agent Zhang <agentzh@gmail.com>

COPYRIGHT

Top

SEE ALSO

Top

WWW::Baidu, Encode.


WWW-Baidu documentation Contained in the WWW-Baidu distribution.

package WWW::Baidu::Record;

use strict;
use warnings;
use base qw(Class::Accessor);

our $VERSION = '0.06';

__PACKAGE__->mk_ro_accessors(
    qw/ title url summary size date cached_url /
);

1;
__END__