⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 result.pm

📁 Yahoo!search API. 用于搜索引擎接口
💻 PM
📖 第 1 页 / 共 3 页
字号:
is returned as html.=cutsub Publisher{    return _text_or_html(Publisher => @_);}###########################################################################=item $Result->Restrictions(<Appropriate for B<Image>, and B<Video> search results>)A (possibly zero-length) string containing zero or more of the followingspace-separated words:  noframe  noinlineSee Yahoo!'s web site (http://developer.yahoo.net/) for information on them.=cutsub Restrictions{    my $Result = shift; #self    if (not defined $Result->{Restrictions}) {        return "";    } else {        return $Result->{Restrictions};    }}##############################################################################=item $Result->Bytes(I<Appropriate for B<Image>, and B<Video> search results>)The size of the image/video item, in bytes.=cutsub Bytes{    my $Result = shift; #self    if ($Result->{FileSize}) {        return $Result->{FileSize};    } else {        return ();    }}##############################################################################=item $Result->Channels(I<Appropriate for B<Video> search results>)Returns the number of channels in the audio, if known.Examples are "1", "2", "4.1", "5.1", etc....=cutsub Channels{    my $Result = shift; # self    if ($Result->{Channels}) {        return $Result->{Channels};    } else {        return ();    }}##############################################################################=item $Result->Seconds(I<Appropriate for B<Video> search results>)Returns the duration of the video clip, if known, in (possibly fractional)seconds.=cutsub Seconds{    my $Result = shift; #self    if ($Result->{Duration}) {        return $Result->{Duration};    }    return ();}##############################################################################=item $Result->Duration(I<Appropriate for B<Video> search results>)Returns a string representing the duration of the video clip, if known, inthe form of "37 sec", "1:23", or "4:56:23", as appropriate.B<Bugs>: English-centric=cutsub Duration{    my $Result = shift; #self    if (my $sec = $Result->Seconds)    {        if ($sec < 60) {            return sprintf "%d sec", $sec;        }        if ($sec < 3600) {            return sprintf "%d:%02d", int($sec/60), $sec%60;        }        my $hours = int($sec/3600);        $sec = $sec % 3600;        return sprintf "%d:%02d:%02d", $hours, int($sec/60), $sec%60;    }    return ();}##############################################################################=item $Result->Streaming(I<Appropriate for B<Video> search results>)Returns "1" if the multimedia is streaming, "0" if not.If not known, an empty list is returned.=cutsub Streaming{    my $Result = shift; #self    my $Stream = $Result->{Streaming} || '';    if ($Stream eq 'true') {        return 1;    } elsif  ($Stream eq 'false') {        return 0;    } else {        return ();    }}##############################################################################=item $Result->SourceUrl(I<Appropriate for B<News> search results>)The main url of the news provider hosting the article that the C<Result>refers to.See the documentation for the C<Url> method for information on theone-argument version of this method.=cutsub SourceUrl{    my $Result = shift; # self    return _url($Result->{NewsSourceUrl}, @_);}##############################################################################=item $Result->SourceName([ I<as_html> ])=item $Result->SourceNameAsHtml(I<Appropriate for B<News> search results>)Similar to C<Title> and C<TitleAsHtml>, but the name of the organizationassociated with the news article (and, by extension, with C<SourceUrl>).=cutsub SourceName{    return _text_or_html(NewsSource => @_);}sub SourceNameAsHtml{    my $Result = shift; # self    return $Result->SourceName(1);}##############################################################################=item $Result->Language(I<Appropriate for B<News> search results>)A code representing the language in which the article is written (e.g. "en"for English, "ja" for Japanese, etc.). See the list of language codes atC<perldoc> Yahoo::Search.=cutsub Language{    my $Result = shift; # self    return $Result->{Language};}##############################################################################=item $Result->PublishTime=item $Result->PublishWhen(I<Appropriate for B<News> search results>)C<PublishTime> is the Unix time associated with the article, e.g.  print "Published ", scalar(localtime $Result->PublishTime), "\n";C<PublishWhen> gives a string along the lines of  3h 25m ago              (if less than 12 hours ago)  Tue 9:47am              (if less than 5 days ago)  Sat, Dec 25             (if less than 100 days ago)  Sat, Dec 25, 2004       (if >= 100 days ago)B<Bug>: C<PublishWhen> is English-centric.=cutsub PublishTime{    my $Result = shift; # self    if (defined $Result->{PublishDate}) {        return $Result->{PublishDate};    } else {        return ();    }}sub PublishWhen{    my $Result = shift; #self    my $time = $Result->PublishTime;    if (not $time) {        return ();    }    my $delta = time - $time;    if ($delta < 3600 * 12)    {        my $h = int( $delta / 3600);        my $m = int(($delta % 3600)/60 + 0.5);        return "${h}h ${m}m ago";    }    if ($delta < 5 * 3600 * 24)    {        ## give day and time        my ($m,$h, $DOW) = (localtime $time)[1,2,6];        my $ampm = "am";        if ($h == 0) {            $h = 12;        } elsif ($h >= 12) {            $ampm = "pm";            if ($h > 12) {                $h -= 12;            }        }        return sprintf("%s %d:%02d%s", $DOW[$DOW], $h, $m, $ampm);    }    if ($delta < 100 * 3600 * 24)    {        my ($D,$M,$Y,$DOW) = (localtime $time)[3..6];        return sprintf("%s %s %d", $DOW[$DOW], $MON[$M], $D);    }    else    {        my ($D,$M,$Y,$DOW) = (localtime $time)[3..6];        return sprintf("%s %s %d, %04d", $DOW[$DOW], $MON[$M], $D, $Y+1900);    }}##############################################################################=item $Result->Address=item $Result->City=item $Result->State=item $Result->Phone(I<Appropriate for B<Local> search results>)Location and Phone number for the business that the C<Result> refers to.=cut## for localsub Address{    my $Result = shift; # self    return $Result->{Address};}sub City{    my $Result = shift; # self    return $Result->{City};}sub State{    my $Result = shift; # self    return $Result->{State};}sub Phone{    my $Result = shift; # self    return $Result->{Phone};}##############################################################################=item $Result->Miles=item $Result->Kilometers(I<Appropriate for B<Local> search results>)The distance (in miles and kilometers) from the location used to make thequery to the location of this result.=cutsub Kilometers{    my $Result = shift; # self    return defined($Result->{Distance}) ? $Result->{Distance} * 1.609 : ();}sub Miles{    my $Result = shift; # self    return defined($Result->{Distance}) ? $Result->{Distance} : ();}##############################################################################=item $Result->Rating(I<Appropriate for B<Local> search results>)Returns the rating associated with the result, if there is one. If there isa rating, it is from 1 (lowest) to 5 (highest) in 0.5-sized steps. If not,nothing is returned.=cutsub Rating{    my $Result = shift; # self    return defined($Result->{Rating}) ? $Result->{Rating} : ();}##############################################################################=item $Result->MapUrl=item $Result->AllMapUrl(I<Appropriate for B<Local> search results>)C<MapUrl> is a url to a Yahoo! Maps map showing the business' location.C<AllMapUrl> is a url to a Yahoo! Maps map showing all the businessesfound in the same result-set that the current C<Result> was part of.See the documentation for the C<Url> method for information on theone-argument versions of these methods.=cutsub MapUrl{    my $Result = shift; # self    return _url($Result->{MapUrl}, @_);}sub AllMapUrl{    my $Result = shift; # self    return _url($Result->Response->MapUrl, @_);}##############################################################################=item $Result->BusinessUrl=item $Result->BusinessClickUrl(I<Appropriate for B<Local> search results>)The business' home page, if available. C<BusinessUrl> is appropriate fordisplay, while C<BusinessClickUrl> is appropriate for the href of a link.See the documentation for the C<Url> method for information on theone-argument versions of these methods.=cutsub BusinessUrl{    my $Result = shift; # self    return _url($Result->{BusinessUrl}, @_);}sub BusinessClickUrl{    my $Result = shift; # self    return _url($Result->{BusinessClickUrl} || $Result->{BusinessUrl}, @_);}##############################################################################=item $Result->Term([ I<as_html> ])=item $Result->TermAsHtml(I<Appropriate for B<Spell>, B<Related>, and B<Terms> search results>)C<Term> returns the term associated with the result. If an optionalargument is provided and is true, the term text is returned as html.C<TermAsHtml> is the same as  $Result->Term(1)=cutsub Term{    _text_or_html(Term => @_);}sub TermAsHtml{    my $Result = shift; #self    return $Result->Term(1);}##############################################################################=pod=back=head1 CopyrightCopyright 2007 Yahoo! Inc.=head1 AuthorJeffrey Friedl (jfriedl@yahoo.com)=cut1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -