NAME
Bing::OpenSearch - Access the OpenSearch compliant RSS interface of the Bing API version 2.0.
VERSION
Version 0.0.2
SYNOPSIS
use strict;
use warnings;
use Bing::OpenSearch;
# Query Bing Image search space for 'Greece'
my $response = Bing::OpenSearch->Query( 'Greece', { sourceType => 'Image',
offset => 0,
count => 10,
market => 'en-us'
}
);
print "Query URL: ", $response->queryURL,"\n";
print "Number of Results: ", $response->totalResults,"\n";
for my $item ($response->results) { # parse results and print data
print "title: ", $item->title,"\n";
print "link : ", $item->link,"\n";
print "guid : ", $item->guid,"\n";
if ($item->description) {
print "description: ", $item->description,"\n";
}
if ($item->pubDate) {
print "pubDate: ", $item->pubDate,"\n";
}
if ($response->space eq 'Image') { # ONLY for Image search space:
print "media-content-url : ", $item->media_content->url,"\n";
print "media-content-height : ", $item->media_content->height,"\n";
print "media-content-width : ", $item->media_content->width,"\n";
print "media-content-fileSize: ", $item->media_content->fileSize,"\n";
print "media-content-type : ", $item->media_content->type,"\n";
print "media-thumbnail-url : ", $item->media_thumbnail->url,"\n";
print "media-thumbnail-height: ", $item->media_thumbnail->height,"\n";
print "media-thumbnail-width : ", $item->media_thumbnail->width,"\n";
}
print "\n";
}
# save the response feed to an RSS UTF-8 file
$response->save('bing_response.rss');
DESCRIPTION
Bing::OpenSearch facilitates searching Bing through its API Version 2.0 via the OpenSearch compliant RSS interface. The RSS endpoint is anonymous; it doesn't require an AppID.
The following search spaces (sourceTypes) are supported:
Web - searches for web content.
Image - searches for images on the web.
INTERFACE
Query( $searchTerms [, \%params] )
Searches Bing for the given query ($searchTerms) using the given search parameters and returns a Bing::OpenSearch::Response object.
Valid search parameters include:
sourceType - search space, default is Web.
offset - startIndex, default is 0. Indicates how far into the result set you are currently processing.
count - number of results requested, default is 10. The maximum number of results returned from Bing API version 2.0 is 50. However, if you want more results, you can submit multiple queries and utilize the offset parameter.
market - language code such as en-us (English), el-gr (Greek), es-es (Spanish), etc. If provided, attempts to restrict the results to those in the given language.
Note that all of these parameters are optional.
DEPENDENCIES
XML::LibXML
LWP::UserAgent
Scalar::Util
Class::Std::Utils
Encode
version
Test::More
Test::Exception
Terms of Use
The results returned may not be used, reproduced or transmitted in any manner or for any purpose other than rendering Bing results within an RSS aggregator for your personal, non-commercial use. Any other use requires written permission from Microsoft Corporation. By using these results in any manner whatsoever, you agree to be bound by the foregoing restrictions.
BUGS AND SUGGESTIONS
Any feedback is very welcome. Please contact me for any bugs, comments or suggestions.
ACKNOWLEDGEMENTS
Special thanks to Petr Pajas, Damian Conway, Gisle Aas, Andy Lester, Jeffrey Friedl, Michael G Schwern, Dan Kogai, Adrian Howard, John Peacock, David A P Mitchell and Graham Barr for their great modules and their huge contribution to the Perl community. And most of all to Larry Wall, the man who started it all.
LICENCE AND COPYRIGHT
Copyright (c) 2010, Kostas Ntonas, <kntonas at gmail.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.