Access the Yahoo! Search APIs using pYsearch
pYsearch is an open-source Python library for accessing the Yahoo! Search APIs written by Leif Hedstrom. This overview covers version 2.0, which is included in the Yahoo! Search SDK and can also be downloaded individually from SourceForge.
Basic usage of pYsearch involves creating a search query object and then executing it to get back a results object. Here's an example showing how to search Yahoo! News:
>>> from yahoo.search.news import NewsSearch
>>> srch = NewsSearch('YahooDemo', query='kittens')
>>> info = srch.parse_results()
>>> info.total_results_available
204
>>> info.total_results_returned
10
>>> info.first_result_position
1
>>> for result in info.results:
... print "'%s', from %s" % (result['Title'], result['NewsSource'])
'Cats, kittens on sale for a discount at Winnipeg shelter', from CBC Manitoba
'Singapore playwright Ovidia Yu', from Radio Singapore International
'News Feature', from Rye and Battle Today
...
The standard query returns the first 10 results. To retrieve the next 10, specify a start parameter.
>>> srch = NewsSearch('YahooDemo', query='kittens', start=11)
>>> info = srch.parse_results()
>>> info.total_results_available
204
>>> info.first_result_position
11
Likewise, you can use a results=20 parameter to change the number of results retrieved at a time (up to a maximum of 50). Other NewsSearch parameters reflect the request parameters listed in the News Search API documentation.
pYsearch includes classes for almost all of the Search APIs. You should consult the pYsearch online documentation for details of which class corresponds to which API.
Ready to get started?
By applying for an Application ID for this service, you hereby agree to the Terms of Use
Yahoo! Groups Discussions
view all
Re: Adduser into group in Ldap Server
Wed, 18 Jul 2007
Adduser into group in Ldap Server
Tue, 17 Jul 2007
Term Extractor - Context size limitation?
Wed, 31 Jan 2007
Tue, 26 Dec 2006


Send Your Suggestions