pYsearch-3.1/0000755001174600001440000000000010671606606012007 5ustar leifuserspYsearch-3.1/docs/0000755001174600001440000000000010671606606012737 5ustar leifuserspYsearch-3.1/docs/index.html0000644001174600001440000003554710671606270014747 0ustar leifusers Python: package yahoo.search
 
 
yahoo.search (version 1.19, Thu Jul 7 14:22:16 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/__init__.py

Yahoo Search Web Services
 
This module implements a set of classes and functions to work with the
Yahoo Search Web Services. All results from these services are properly
formatted XML, and this package facilitates for proper parsing of these
result sets. Some of the features include:
 
    * Extendandable API, with replaceable backend XML parsers, and
      I/O interface.
    * Type and value checking on search parameters, including
      automatic type conversion (when appropriate and possible)
    * Flexible return format, including DOM objects, or fully
      parsed result objects
 
 
You can either instantiate a search object directly, or use the factory
function create_search() from the factory module. The supported classes
of searches are:
    
    NewsSearch     - News article search
    VideoSearch    - Video and movie search
    ImageSearch    - Image search
    LocalSearch    - Local area search
 
    WebSearch           - Web search
    ContextSearch       - Web search with a context
    RelatedSuggestion   - Web search Related Suggestion
    SpellingSuggestion  - Web search Spelling Suggestion
 
    TermExtraction - Term Extraction service
 
    AlbumSearch    - Find information about albums
    ArtistSearch   - Information on a particular musical performer
    SongDownload   - Find links to various song providers of a song
    PodcastSearch  - Search for a Podcast site/feed
    SongSearch     - Provide information about songs
 
    PageData       - Shows a list of all pages belonging to a domain
    InlinkData     - Shows the pages from other sites linking to a page
 
 
The different sub-classes of search supports different sets of query
parameters. For details on all allowed parameters, please consult the
specific module documentation.
 
Each of these parameter is implemented as an attribute of each
respective class. For example, you can set parameters like:
 
    from yahoo.search.web import WebSearch
 
    app_id = "YahooDemo"
    srch = WebSearch(app_id)
    srch.query = "Leif Hedstrom"
    srch.results = 40
 
or, if you are using the factory function:
    
    from yahoo.search.factory import create_search
 
    app_id = "YahooDemo"
    srch = create_search("Web", app_id, query="Leif Hedstrom", results=40)
    if srch is not None:
        # srch object ready to use
        ...
    else:
        print "error"
 
or, the last alternative, a combination of the previous two:
 
    import yahoo.search.web
 
    app_id = "YahooDemo"
    srch = web.WebSearch(app_id, query="Leif Hedstrom", results=40)
 
To retrieve a certain parameter value, simply access it as any normal
attribute:
 
    print "Searched for ", srch.query
 
 
For more information on these parameters, and their allowed values, please
see the official Yahoo Search Services documentation available at
 
    http://developer.yahoo.net/
 
Once the webservice object has been created, you can retrieve a parsed
object (typically a DOM object) using the get_results() method:
 
    dom = srch.get_results()
 
This DOM object contains all results, and can be used as is. For easier
use of the results, you can use the built-in results factory, which will
traverse the entire DOM object, and create a list of results objects.
 
    results = srch.parse_results(dom)
 
or, by using the implicit call to get_results():
 
    results = srch.parse_results()
    
The default XML parser and results factories should be adequate for most
users, so use the parse_results() when possible. However, both the XML
parser and the results parser can easily be overriden. See the examples
below for details. More information about the DOM parsers are available
in the yahoo.search.dom module, and it's subclasses.
 
 
EXAMPLES:
 
This simple application will create a search object using the first
command line argument as the "type" (e.g. "web" or "news"), and all
subsequent arguments forms the query string:
 
    #!/usr/bin/python
 
    import sys
    from yahoo.search.factory import create_search
 
    service = sys.argv[1]
    query = " ".join(sys.argv[2:])
    app_id = "YahooDemo"
    srch = create_search(service, app_id, query=query, results=5)
    if srch is None:
        srch = create_search("Web", app_id, query=query, results=5)
 
    dom = srch.get_results()
    results = srch.parse_results(dom)
 
    for res in results:
        url = res.Url
        summary = res['Summary']
        print "%s -> %s" (summary, url)
 
 
The same example using the PyXML 4DOM parser:
 
    #!/usr/bin/python
 
    import sys
    from yahoo.search.factory import create_search
    from xml.dom.ext.reader import Sax2
 
    query = " ".join(sys.argv[2:])
    srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5)
    if srch is not None:
        reader = Sax2.Reader()
        srch.install_xml_parser(reader.fromStream)
        .
        .
        .
 
 
The last example will produce the same query, but uses an HTTP proxy
for the request:
 
    #!/usr/bin/python
 
    import sys
    from yahoo.search.factory import create_search
    import urllib2
 
    query = " ".join(sys.argv[2:])
    srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5)
 
    if srch is not None:
        proxy = urllib2.ProxyHandler({"http" : "http://octopus:3128"})
        opener = urllib2.build_opener(proxy)
        srch.install_opener(opener)
        .
        .
        .
 
 
You can obviously "mix and match" as necessary here. I'm using the
installer methods above for clarity, the APIs allows you to pass those
custom handlers as arguments as well (see the documentation below).

 
Package Contents
       
audio
debug
dom (package)
factory
image
local
news
parser
site
term
version
video
web
webservices

 
Data
        __all__ = ['web', 'news', 'video', 'image', 'local', 'term', 'audio', 'site']
__author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Thu Jul 7 14:22:16 PDT 2005'
__revision__ = '$Id: __init__.py,v 1.19 2007/09/11 21:38:43 zwoop Exp $'
__version__ = '$Revision: 1.19 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.html0000644001174600001440000000240310571215017014732 0ustar leifusers Python: package yahoo
 
 
yahoo
index
/home/leif/hack/pysearch/yahoo/__init__.py

 
Package Contents
       
search (package)
pYsearch-3.1/docs/yahoo.search.audio.html0000644001174600001440000032721710671606266017326 0ustar leifusers Python: module yahoo.search.audio
 
 
yahoo.search.audio (version 1.9, Tue Feb 27 14:08:31 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/audio.py

yahoo.search.audio - Audio Search services module
 
This module implements the the Audio Search web service, to do search
queries on various audio formats.
 
The supported classes of web searches are:
    
    ArtistSearch          - Information on a particular musical performer
    AlbumSearch           - Find information about albums
    SongSearch            - Provide information about songs
    SongDownloadLocation  - Find links to various providers of a song
    PodcastSearch         - Search for a Podcast site/feed
 
 
An application ID (appid) is always required when instantiating a search
object. In addition, each search class takes different set of parameters,
as defined by this table:
 
             AlbumSearch  ArtistSearch  SongSearch  SongDownloadLocation
             -----------  ------------  ----------  --------------------
    type         [X]          [X]          [X]               .
    results      [X]          [X]          [X]              [X]
    start        [X]          [X]          [X]              [X]
                                         
    artist       [X]          [X]          [X]               .
    artistid     [X]          [X]          [X]               .
    album        [X]           .           [X]               .
    albumid      [X]           .           [X]               .
 
    song          .            .           [X]              [X]
    songid        .            .           [X]               .
 
    source        .            .            .               [X]
 
    output       [X]          [X]          [X]              [X]
    callback     [X]          [X]          [X]              [X]
 
 
Each of these parameter is implemented as an attribute of each
respective class. For example, you can set parameters like:
 
    from yahoo.search.audio import AlbumSearch
 
    srch = AlbumSearch(app_id="YahooDemo")
    srch.album = "Like"
    srch.results = 40
 
    for res in srch.parse_results():
       print res.Artist
 
The PodcastSearch service takes a different set of parameters, see the
documentation for this class for further details.

 
Modules
       
types
yahoo

 
Classes
       
yahoo.search._CommonSearch(yahoo.search._Search)
PodcastSearch
_Audio(yahoo.search._Search)
AlbumSearch
ArtistSearch
SongDownloadLocation
SongSearch

 
class AlbumSearch(_Audio)
    AlbumSearch - perform a Yahoo Album Search
 
This class implements the Album Search web service APIs, which allows
you to find information on music albums. Supported parameters are:
 
    results    - The number of results to return (1-50).
    start      - The starting result position to return (1-based).
                 The finishing position (start + results - 1) cannot
                 exceed 1000.
    artist     - The artist or partial artist string to search for
                 (UTF-8 encoded).
    artistid   - The specific id for an artist.
    album      - The album name or partial album string to search for
                 (UTF-8 encoded).
    albumid    - The specific id for an album. Ids are internal to the
                 Music Search Service and will be returned with album
                 references. At least one of artist, artistid, album or
                 albumid is required.
    type       - The kind of search to submit:
                    * "all" returns results with all query terms.
                    * "any" resturns results with one or more of the
                      query terms.
                    * "phrase" returns results containing the query
                      terms as a phrase.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/search/audio/V1/albumSearch.html
 
 
Method resolution order:
AlbumSearch
_Audio
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'albumSearch'
SERVICE = 'AudioSearchService'

Properties inherited from _Audio:
download_sources
List of all supported download sources
get = _get_download_sources(self)
Get the list of all supported download sources.

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
class ArtistSearch(_Audio)
    ArtistSearch - perform a Yahoo Artist Search
 
This class implements the Artist Search web service APIs. Allowed
parameters are:
 
    results    - The number of results to return (1-50).
    start      - The starting result position to return (1-based).
                 The finishing position (start + results - 1) cannot
                 exceed 1000.
    artist     - The artist or partial artist string to search for
                 (UTF-8 encoded).
    artistid   - The specific id for an artist. Ids are internal to
                 the Music Search Service and will be returned with
                 artist references. One of artist or artistid is
                 always required.
    type       - The kind of search to submit:
                    * "all" returns results with all query terms.
                    * "any" resturns results with one or more of the
                      query terms.
                    * "phrase" returns results containing the query
                      terms as a phrase.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/search/audio/V1/artistSearch.html
 
 
Method resolution order:
ArtistSearch
_Audio
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'artistSearch'
SERVICE = 'AudioSearchService'

Properties inherited from _Audio:
download_sources
List of all supported download sources
get = _get_download_sources(self)
Get the list of all supported download sources.

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
class PodcastSearch(yahoo.search._CommonSearch)
    PodcastSearch - perform a Yahoo Podcast Search
 
This class implements the Podcast Search web service APIs. Allowed
parameters are:
 
    query        - The query to search for (UTF-8 encoded).
    type         - The kind of search to submit (all, any or phrase).
    results      - The number of results to return (1-50).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    format       - Specifies the kind of audio file to search for.
    adult_ok     - The service filters out adult content by default.
                   Enter a 1 to allow adult content.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Supported formats are
 
    all       - All formats (default)
    aiff      - AIFF
    midi      - MIDI file
    mp3       - MP3 (MPEG-3) format
    msmedia   - Microsoft media
    quicktime - Apple QuickTime
    realmedia - Real media
    wav       - Wave file
    other     - Other
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/audio/V1/podcastSearch.html
 
 
Method resolution order:
PodcastSearch
yahoo.search._CommonSearch
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'podcastSearch'
SERVICE = 'AudioSearchService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
class SongDownloadLocation(_Audio)
    SongDownloadLocation - find places to download songs
 
This class implements the Song Download Location web service APIs.
Allowed parameters are:
 
    songid     - The specific id for a song.
    results    - The number of results to return (1-50).
    start      - The starting result position to return (1-based). The
                 finishing position (start + results - 1) cannot exceed
                 1000.
    source     - The source of the download. You may specify multiple
                 values, e.g. ["yahoo", "itunes"].
    results    - The number of results to return (1-50).
    start      - The starting result position to return (1-based).
                 The finishing position (start + results - 1) cannot
                 exceed 1000.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/search/audio/V1/artistSearch.html
 
 
Method resolution order:
SongDownloadLocation
_Audio
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'songDownloadLocation'
SERVICE = 'AudioSearchService'

Properties inherited from _Audio:
download_sources
List of all supported download sources
get = _get_download_sources(self)
Get the list of all supported download sources.

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
class SongSearch(_Audio)
    AlbumSearch - perform a Yahoo Album Search
 
This class implements the Album Search web service APIs, which allows
you to find information on music albums. Supported parameters are:
 
    results    - The number of results to return (1-50).
    start      - The starting result position to return (1-based).
                 The finishing position (start + results - 1) cannot
                 exceed 1000.
    artist     - The artist or partial artist string to search for
                 (UTF-8 encoded).
    artistid   - The specific id for an artist.
    album      - The album name to search for (UTF-8 encoded).
    albumid    - The specific id for an album.
    song       - The song title to search for (UTF-8 encoded).
    songid     - The specific id for a song. At least one of artist,
                 artistid, album, albumid, song or songid is required.
    type       - The kind of search to submit:
                    * "all" returns results with all query terms.
                    * "any" resturns results with one or more of the
                      query terms.
                    * "phrase" returns results containing the query
                      terms as a phrase.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/search/audio/V1/songSearch.html
 
 
Method resolution order:
SongSearch
_Audio
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'songSearch'
SERVICE = 'AudioSearchService'

Properties inherited from _Audio:
download_sources
List of all supported download sources
get = _get_download_sources(self)
Get the list of all supported download sources.

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
Data
        DOWNLOAD_SOURCES = {'artistdirect': '', 'audiolunchbox': '', 'buymusic': '', 'dmusic': '', 'emusic': '', 'epitonic': '', 'garageband': '', 'itunes': '', 'livedownloads': '', 'mapster': '', ...}
__author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 14:08:31 MST 2007'
__revision__ = '$Id: audio.py,v 1.9 2007/02/28 05:20:09 zwoop Exp $'
__version__ = '$Revision: 1.9 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.debug.html0000644001174600001440000001320010671606267017274 0ustar leifusers Python: module yahoo.search.debug
 
 
yahoo.search.debug (version 1.7, Wed Oct 26 11:15:36 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/debug.py

yahoo.search.debug - Debugging utilities
 
This module defines and provides some debugging utilities that can
be used when you encounter problems with the search APIs. Most
interesting is the various debugging levels:
 
     HTTP     - Various HTTP protocol related information.
     PARAMS   - Show debugging information about CGI parameters.
     PARSING  - Show parsing processing.
 
     RAWXML   - Show the raw XML.
 
     ALL      - Show everything.

 
Modules
       
sys

 
Classes
       
__builtin__.object
Debuggable

 
class Debuggable(__builtin__.object)
    Debuggable - Simple "base" class to implement debugging. You
should use this instead of object as a base class. The only
useful member function is _debug_msg, intentionally made
private to avoid exposing it in docs and APIs.
 
  Methods defined here:
__init__(self, debug_level=0)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
Data
        DEBUG_LEVELS = {'ALL': 4294967295L, 'HTTP': 1, 'PARAMS': 2, 'PARSING': 4, 'RAWXML': 2147483648L}
__author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Wed Oct 26 11:15:36 PDT 2005'
__revision__ = '$Id: debug.py,v 1.7 2005/10/26 20:32:27 zwoop Exp $'
__version__ = '$Revision: 1.7 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.audio.html0000644001174600001440000012020510571215017020055 0ustar leifusers Python: module yahoo.search.dom.audio
 
 
yahoo.search.dom.audio (version 1.4, Tue Feb 27 14:19:41 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/dom/audio.py

DOM parser for Audio search results
 
Implement a simple DOM parser for the Yahoo Search Web Services
audio search APIs.

 
Modules
       
yahoo.search.dom
yahoo.search.parser

 
Classes
       
yahoo.search.dom.DOMResultParser(yahoo.search.parser.ResultParser)
PodcastSearch
SongDownloadLocation
_AudioParser(yahoo.search.dom.DOMResultParser)
AlbumSearch
ArtistSearch
SongSearch

 
class AlbumSearch(_AudioParser)
    AlbumSearch - DOM parser for Album Search
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title          - The title of the album.
    Artist         - The performer of the album, and the unique ID
    Publisher      - The publisher of the album.
    ReleaseDate    - The date of the album's release.
    Id             - Internal ID of the album, unique identifier.
 
The following attributes are optional, and might not be set:
 
    Tracks         - Number of tracks on the album.
    Thumbnail      - The URL of a thumbnail picture of the album cover.
    RelatedAlbums  - Contains a list of related (similar) albums (IDs).
 
Thumbnail is in turn another dictionary, which will have the following
keys:
 
    Url             - URL of the thumbnail.
    Height          - Height of the thumbnail, in pixels (optional).
    Width           - Width of the thumbnail, in pixels (optional).
 
The two attributes Artist and RelatedAlbums are both lists of
dictionaries, with the following two keys:
 
    Name            - Textual "name" value.
    Id              - Unique identifier (internal yahoo ID).
 
 
Example:
    results = ws.parse_results()
    for res in results:
        print "%s - %s bytes" % (res.Artist.Name, res.Artist.Id)
 
 
Method resolution order:
AlbumSearch
_AudioParser
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
class ArtistSearch(_AudioParser)
    ArtistSearch - DOM parser for Artist Search
 
 Each result is a dictionary populated with the extracted data from the
 XML results. The following keys are always available:
 
     Name           - The name of the artist.
     Id             - Internal ID of the artist, unique identifier.
 
 The following attributes are optional, and might not be set:
 
     Thumbnail      - The URL of the thumbnail file.
     RelatedArtists - Contains a list of related artists that fans of
                      the artist in this Result might like.
     PopularSongs   - Contains a list of popular songs by this artist.
     YahooMusicPage - The URL to link to the artist's page on the
                      Yahoo Music site. This can be empty!
 
 Thumbnail is in turn another dictionary, which will have the following
 keys:
 
     Url             - URL of the thumbnail.
     Height          - Height of the thumbnail, in pixels (optional).
     Width           - Width of the thumbnail, in pixels (optional).
 
Both RelatedArtist and PopularSongs are lists of IDs, which can be
used as an identifier into subsequent Yahoo Audio search calls.
 
 Example:
     results = ws.parse_results()
     for res in results:
         print "%s - %s bytes" % (res.Name, res.YahooMusicPage)
 
 
Method resolution order:
ArtistSearch
_AudioParser
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
class PodcastSearch(yahoo.search.dom.DOMResultParser)
    PodcastSearch - DOM parser for Podcast Search
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title            - The title of the audio file.
    Summary          - Summary text associated with the audio file.
    Url              - The URL for the audio file or stream.
    ClickUrl         - The URL for linking to the audio file.
    RefererUrl       - The URL of the web page hosting the content.
    FileSize         - The size of the file, in bytes.
    FileFormat       - One of aiff, midi, mp3, msmedia, quicktime,
                       realmedia, wav or other.
    Duration         - The duration of the audio file in seconds.
    Streaming        - Whether the audio file is streaming or not.
 
The following attributes are optional, and might not be set:
 
    SampleSize       - The number of bits used in sampling the sound.
    Channels         - The number of channels in the audio. Usually
                       1 (mono) or 2 (stereo).
    Publisher        - The creator of the video file.
    Restrictions     - Provides any restrictions for this media
                       object. Restrictions include noframe and
                       noinline. See developer site for more info.
    Copyright        - The copyright owner.
 
If present, the Thumbnail value is in turn another dictionary, which will
have these keys:
 
    Url             - URL of the thumbnail.
    Height          - Height of the thumbnail in pixels (optional).
    Width           - Width of the thumbnail in pixels (optional).
 
 
Example:
 
    results = ws.parse_results(dom)
    for res in results:
        print "%s - %s bytes" % (res.Title, res.FileSize)
 
 
Method resolution order:
PodcastSearch
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
class SongDownloadLocation(yahoo.search.dom.DOMResultParser)
    SongDownloadLocation - DOM parser for Song Download Location
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Source        - The source provider for the file.
    Url           - The url for accessing the file.
    Format        - The format the file has been encoded in.
 
The following attributes are optional, and might not be set:
 
    Price         - The price, in dollars, of the song.
    Length        - The length of the song in seconds.
    Channels      - The number of channels. Usually 1 (mono) or
                    2 (stereo).
    Restrictions  - A space-separated list of restrictions:
                      * drm denotes files with some form of digital
                        rights management.
                      * subrequired means a subscription to the
                        appropriate service is required.
                      * subnotrequired means a subscription to the
                        appropriate service is not required.
                      * win denotes files that will play on Windows.
                      * mac denotes files that will play on Macintosh.
                      * copyokay means this file may be copied.
                      * copynotokay means this file may not be copied.
                      * cdokay means this file may be burned to CD.
    Quality       - A quality metric for files found on the web. Values
                    range from 1 (worst) to 5 (best).
 
Example:
    results = ws.parse_results()
    for res in results:
        print "%s - %s bytes" % (res.Name, res.YahooMusicPage)
 
 
Method resolution order:
SongDownloadLocation
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
class SongSearch(_AudioParser)
    SongSearch - DOM parser for Song Search
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title          - The title of the song.
    Id             - Internal ID of the song, unique identifier.
    Album          - The album from which the song was taken, and ID.
    Artist         - The performer of the album, and the unique ID.
    Publisher      - The publisher of the album.
    Length         - The length of the song in seconds.
    ReleaseDate    - The date of the album's release.
    Track          - The track number on the album.
    ClickUrl       - The URL for linking to the audio file.
 
The following attributes are optional, and might not be set:
 
    Thumbnail      - The URL of a thumbnail picture of the album cover.
 
Thumbnail is in turn another dictionary, which will have the following
keys:
 
    Url             - URL of the thumbnail.
    Height          - Height of the thumbnail, in pixels (optional).
    Width           - Width of the thumbnail, in pixels (optional).
 
The two attributes Artist and RelatedAlbums are both lists of dicts,
with the keys:
 
    Name            - Textual "name" value.
    Id              - Unique identifier (internal yahoo ID).
 
 
Example:
    results = ws.parse_results()
    for res in results:
        print "%s - %s bytes" % (res.Artist.Name, res.Title)
 
 
Method resolution order:
SongSearch
_AudioParser
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 14:19:41 MST 2007'
__revision__ = '$Id: audio.py,v 1.4 2007/02/28 05:20:11 zwoop Exp $'
__version__ = '$Revision: 1.4 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.html0000644001174600001440000001714610571215014016763 0ustar leifusers Python: package yahoo.search.dom
 
 
yahoo.search.dom (version 1.6, Tue Feb 27 16:27:58 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/dom/__init__.py

Base class for search results parsing
 
This package implements the interface and base class that should be
used for all parsers of the web results. It is used by the DOM parsers
that we provide as defaults.

 
Package Contents
       
audio
image
local
myweb
news
site
term
video
web

 
Classes
       
yahoo.search.parser.ResultParser(__builtin__.object)
DOMResultParser

 
class DOMResultParser(yahoo.search.parser.ResultParser)
    DomResultParser - Base class for Yahoo Search DOM result parsers
 
This is a DOM specific parser that is used as a base class for all
Yahoo Search result parsers. It obviously must implement the main entry
entry point, parse_results().
 
 
Method resolution order:
DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods defined here:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 16:27:58 MST 2007'
__revision__ = '$Id: __init__.py,v 1.6 2007/02/28 05:20:11 zwoop Exp $'
__version__ = '$Revision: 1.6 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.image.html0000644001174600001440000002535610571215015020047 0ustar leifusers Python: module yahoo.search.dom.image
 
 
yahoo.search.dom.image (version 1.5, Thu Oct 27 10:47:11 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/dom/image.py

DOM parser for Image search results
 
Implement a simple DOM parser for the Yahoo Search Web Services
image search APIs.

 
Modules
       
yahoo.search.dom
yahoo.search.parser

 
Classes
       
yahoo.search.dom.DOMResultParser(yahoo.search.parser.ResultParser)
ImageSearch

 
class ImageSearch(yahoo.search.dom.DOMResultParser)
    ImageSearch - DOM parser for Image Search
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title            - The title of the image file.
    Summary          - Summary text associated with the image file.
    Url              - The URL for the image file or stream.
    ClickUrl         - The URL for linking to the image file.
    RefererUrl       - The URL of the web page hosting the content.
    FileSize         - The size of the file, in bytes.
    FileFormat       - One of bmp, gif, jpg or png.
    Thumbnail        - The URL of the thumbnail file.
 
The following attributes are optional, and might not be set:
 
    Height           - The height of the image in pixels.
    Width            - The width of the image in pixels.
    Publisher        - The creator of the image file.
    Restrictions     - Provides any restrictions for this media
                       object. Restrictions include noframe and
                       noinline.
    Copyright        - The copyright owner.
 
The Thumbnail is in turn another dictionary, which will have the
following keys:
 
    Url             - URL of the thumbnail.
    Height          - Height of the thumbnail, in pixels (optional).
    Width           - Width of the thumbnail, in pixels (optional).
 
 
Example:
    results = ws.parse_results(dom)
    for res in results:
        print "%s - %s bytes" % (res.Title, res.FileSize)
 
 
Method resolution order:
ImageSearch
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Thu Oct 27 10:47:11 PDT 2005'
__revision__ = '$Id: image.py,v 1.5 2005/10/27 18:07:59 zwoop Exp $'
__version__ = '$Revision: 1.5 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.local.html0000644001174600001440000003304310571215016020050 0ustar leifusers Python: module yahoo.search.dom.local
 
 
yahoo.search.dom.local (version 1.7, Tue Feb 27 16:57:05 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/dom/local.py

DOM parser for Local search results
 
Implement a simple DOM parser for the Yahoo Search Web Services
local search APIs.

 
Modules
       
yahoo.search.dom
yahoo.search.parser

 
Classes
       
yahoo.search.dom.DOMResultParser(yahoo.search.parser.ResultParser)
LocalSearch

 
class LocalSearch(yahoo.search.dom.DOMResultParser)
    LocalSearch - DOM parser for Local Search
 
This subclass of the SearchParser extends the parser with support for
the Result Set Map Url. This adds an extra attribute
 
    results.result_set_map_url
 
This attribute holds a URL pointing to a Yahoo Locals map with all the
results shown on the map.
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title            - Name of the result.
    Address          - Street address of the result.
    City             - City in which the result is located.
    State            - State in which the result is located.
    Phone            - Phone number of the business, if known.
    Latitude         - The latitude of the location.
    Longitude        - The longitude of the location.
    Distance         - The distance to the business or service.
    Url              - The URL for the local file or stream.
    ClickUrl         - The URL for linking to the detailed page.
    MapUrl           - The URL of a map for the address.
    Categories       - Contains all the categories in which this
                       listing is classified.
 
The following attributes are optional, and might not be set:
 
    Rating           - Rating information (see below)
    BusinessUrl      - The URL fo the business website, if known.
    BusinessClickUrl - The URL for linking to the business website,
                       if known.
 
The Rating dictionary contains the following keys:
 
    AverageRating     - Average score of end-user ratings for the
                        business or service. 
    TotalRatings      - The total number of ratings submitted for
                        the business or service.
    TotalReviews      - The total number of reviews submitted for
                        the business or service. Reviews can be viewed
                        at the location pointed to by the ClickUrl tag.
    LastReviewDate    - The date of the last review submitted for the
                        business or service unix timestamp format. 
    LastReviewIntro   - The first few words of the last review
                        submitted for the business or service.
 
Categories is a list of tuples with
 
    Name   - Textual "name" value
    Id     - Unique identifier (internal yahoo ID).
    
 
Example:
    results = ws.parse_results()
    for res in results:
        print "%s  is %s %s away" % (res.Title, res.Distance[0],
                                     res.Distance[1])
 
 
Method resolution order:
LocalSearch
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods defined here:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
parse_results(self, dom_object)
Specialized DOM parser for LocalSearch, to allow for the Map
URL in the result.

Data descriptors defined here:
ResultSetMapUrl
The Yahoo Locals map with all the results
result_set_map_url
The Yahoo Locals map with all the results

Methods inherited from yahoo.search.parser.ResultParser:
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 16:57:05 MST 2007'
__revision__ = '$Id: local.py,v 1.7 2007/02/28 05:20:11 zwoop Exp $'
__version__ = '$Revision: 1.7 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.myweb.html0000644001174600001440000005654310571215017020114 0ustar leifusers Python: module yahoo.search.dom.myweb
 
 
yahoo.search.dom.myweb (version 1.4, Thu Oct 27 10:47:35 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/dom/myweb.py

DOM parser for MyWeb search results
 
Implement a simple DOM parser for the Yahoo Search Web Services
MyWeb and MyWeb2 search APIs.

 
Modules
       
yahoo.search.dom

 
Classes
       
yahoo.search.dom.DOMResultParser(yahoo.search.parser.ResultParser)
ListFolders
ListUrls
TagSearch
UrlSearch

 
class ListFolders(yahoo.search.dom.DOMResultParser)
    ListFolders - DOM parser for MyWeb Public Folders
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title            - The title of the folder.
    UrlCount         - The number of URLs stored in this folder.
 
 
Example:
    results = ws.parse_results(dom)
    for res in results:
        print "%s [%d]" % (res.Title, res.UrlCount)
 
 
Method resolution order:
ListFolders
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
class ListUrls(yahoo.search.dom.DOMResultParser)
    ListUrls - DOM parser for MyWeb Stored URLs
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title            - The title of the folder.
    Summary          - Summary text associated with the web page.
    Url              - The URL for the web page.
    ClickUrl         - The URL for linking to the page.
    Note             - Any note the Yahoo! user has chosen to annotate
                       the URL with.
    StoreDate        - The date the URL was stored, unix timestamp format.
 
 
Example:
    results = ws.parse_results(dom)
    for res in results:
        print "%s - %s" % (res.Title, res.Url)
 
 
Method resolution order:
ListUrls
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
class TagSearch(yahoo.search.dom.DOMResultParser)
    UrlSearch - DOM parser for MyWeb2 Tag Search
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Tag          - The value of the tag.
    Frequency    - The number of times the tag has been used publicly. IF
                   the query is filtered by yahoo ID, and/or URL, it will
                   return the number of times the tag has been used by
                   that user (and/or on that URL).
    Date         - The date the URL was stored, in unix timestamp format.
 
 
Method resolution order:
TagSearch
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
class UrlSearch(yahoo.search.dom.DOMResultParser)
    UrlSearch - DOM parser for MyWeb2 URL search
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title        - The title of the web page.
    Summary      - Summary text associated with the web page.
    Url          - The URL for the web page.
    ClickUrl     - The URL for linking to the page.
    User         - The Yahoo! ID of the last user to store the URL (or
                   the user specified with the yahooid parameter).
    Note         - Any note the Yahoo! user has chosen to annotate
                   the URL with.
    Date         - The date the URL was stored, in unix timestamp format.
    Tags         - The tags associated with this URL.
 
 
Method resolution order:
UrlSearch
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Thu Oct 27 10:47:35 PDT 2005'
__revision__ = '$Id: myweb.py,v 1.4 2005/10/27 18:07:59 zwoop Exp $'
__version__ = '$Revision: 1.4 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.news.html0000644001174600001440000002260010571215015017726 0ustar leifusers Python: module yahoo.search.dom.news
 
 
yahoo.search.dom.news (version 1.2, Wed Oct 26 15:02:17 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/dom/news.py

DOM parser for News search results
 
Implement a simple DOM parser for the Yahoo Search Web Services
news search APIs.

 
Modules
       
yahoo.search.dom

 
Classes
       
yahoo.search.dom.DOMResultParser(yahoo.search.parser.ResultParser)
NewsSearch

 
class NewsSearch(yahoo.search.dom.DOMResultParser)
    NewsSearch - DOM parser for News Search
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title            - Title of the article.
    Summary          - Summary of the text associated with the article.
    Url              - The URL for the article.
    ClickUrl         - The URL for linking to the article.
    NewsSource       - The company that distributed the news article.
    NewsSourceUrl    - The URL for the news source.
    Language         - Language of the News article.
    PubslishDate     - Publish date of the article.
 
The following attributes are optional, and might not be set:
 
    ModificationDate - Date entry was modified.
    Thumbnail        - The URL of the thumbnail file.
 
If present, the Thumbnail value is in turn another dictionary, which will
have these keys:
 
    Url             - URL of the thumbnail.
    Height          - Height of the thumbnail in pixels (optional).
    Width           - Width of the thumbnail in pixels (optional).
 
 
Method resolution order:
NewsSearch
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Wed Oct 26 15:02:17 PDT 2005'
__revision__ = '$Id: news.py,v 1.2 2005/10/27 02:59:15 zwoop Exp $'
__version__ = '$Revision: 1.2 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.site.html0000644001174600001440000003763110671605246017742 0ustar leifusers Python: module yahoo.search.dom.site
 
 
yahoo.search.dom.site (version 1.3, Wed Feb 28 16:21:14 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/dom/site.py

DOM parser for Site Explorer results
 
Implement a simple DOM parsers for the Yahoo Search Web Services site
explorer APIs. This provides parser for the following classes:
 
    PageData      - Shows a list of all pages belonging to a domain
    InlinkData    - Shows the pages from other sites linking in to a page

 
Modules
       
yahoo.search.dom

 
Classes
       
yahoo.search.dom.DOMResultParser(yahoo.search.parser.ResultParser)
PageData
UpdateNotification

 
class PageData(yahoo.search.dom.DOMResultParser)
    PageData - DOM parser for PageData results
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title            - The title of the web page.
    Url              - The URL for the web page.
    ClickUrl         - The URL for linking to the page.
 
 
Example:
    results = ws.parse_results(dom)
    for res in results:
        print "%s - %s" % (res.Title, res.Url)
 
 
Method resolution order:
PageData
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Properties inherited from yahoo.search.parser.ResultParser:
firstResultPosition
The first result position
get = _get_first_result_position(self)
Get the first result position.
first_result_position
The first result position
get = _get_first_result_position(self)
Get the first result position.
results
The list of all results
get = _get_results(self)
Get the results.
service
The Search Web Service object for this results parser
get = _get_service(self)
Get the service for this DOM parser.
set = _set_service(self, service)
Set the service for this DOM parser.
totalResultsAvailable
Total number of results for the query
get = _get_total_results_available(self)
Get the total number of results for the query.
totalResultsReturned
The number of results returned
get = _get_total_results_returned(self)
Get the number of results returned.
total_results_available
Total number of results for the query
get = _get_total_results_available(self)
Get the total number of results for the query.
total_results_returned
The number of results returned
get = _get_total_results_returned(self)
Get the number of results returned.

Data and other attributes inherited from yahoo.search.parser.ResultParser:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'ResultParser' objects>
list of weak references to the object (if defined)

 
class UpdateNotification(yahoo.search.dom.DOMResultParser)
    UpdateNotification - DOM parser for Site Update Notification
 
The return value for this is always a list with one single
element, a dictionary with
 
    Success    - Did we succeed or not (True or False)
    Error      - In case of a failure, the error message
 
 
Method resolution order:
UpdateNotification
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods defined here:
parse_results(self, dom_object)
Internal method to parse one Result node

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Properties inherited from yahoo.search.parser.ResultParser:
firstResultPosition
The first result position
get = _get_first_result_position(self)
Get the first result position.
first_result_position
The first result position
get = _get_first_result_position(self)
Get the first result position.
results
The list of all results
get = _get_results(self)
Get the results.
service
The Search Web Service object for this results parser
get = _get_service(self)
Get the service for this DOM parser.
set = _set_service(self, service)
Set the service for this DOM parser.
totalResultsAvailable
Total number of results for the query
get = _get_total_results_available(self)
Get the total number of results for the query.
totalResultsReturned
The number of results returned
get = _get_total_results_returned(self)
Get the number of results returned.
total_results_available
Total number of results for the query
get = _get_total_results_available(self)
Get the total number of results for the query.
total_results_returned
The number of results returned
get = _get_total_results_returned(self)
Get the number of results returned.

Data and other attributes inherited from yahoo.search.parser.ResultParser:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'ResultParser' objects>
list of weak references to the object (if defined)

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Wed Feb 28 16:21:14 MST 2007'
__revision__ = '$Id: site.py,v 1.3 2007/02/28 23:21:30 zwoop Exp $'
__version__ = '$Revision: 1.3 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.term.html0000644001174600001440000001660310571215016017730 0ustar leifusers Python: module yahoo.search.dom.term
 
 
yahoo.search.dom.term (version 1.1, Sat Oct 15 15:44:48 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/dom/term.py

DOM parser for Term Extraction search results
 
Implement a simple DOM parser for the Yahoo Search Web Services
term extraction search APIs.

 
Modules
       
yahoo.search.dom

 
Classes
       
yahoo.search.dom.DOMResultParser(yahoo.search.parser.ResultParser)
TermExtraction

 
class TermExtraction(yahoo.search.dom.DOMResultParser)
    TermExtraction - DOM parser for Term Extraction queries
 
Return the list of words and phrases related to the context and
the optional query string. The results from this search are slightly
different compared to other services, it's just a simple list of
words and phrases.
 
 
Method resolution order:
TermExtraction
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Sat Oct 15 15:44:48 PDT 2005'
__revision__ = '$Id: term.py,v 1.1 2005/10/17 01:41:47 zwoop Exp $'
__version__ = '$Revision: 1.1 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.video.html0000644001174600001440000002745110571215016020072 0ustar leifusers Python: module yahoo.search.dom.video
 
 
yahoo.search.dom.video (version 1.4, Thu Oct 27 10:47:24 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/dom/video.py

DOM parser for Video search results
 
Implement a simple DOM parser for the Yahoo Search Web Services
video search APIs.

 
Modules
       
yahoo.search.dom
yahoo.search.parser

 
Classes
       
yahoo.search.dom.DOMResultParser(yahoo.search.parser.ResultParser)
VideoSearch

 
class VideoSearch(yahoo.search.dom.DOMResultParser)
    VideoSearch - DOM parser for Video Search
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title            - The title of the video file.
    Summary          - Summary text associated with the video file.
    Url              - The URL for the video file or stream.
    ClickUrl         - The URL for linking to the video file.
    RefererUrl       - The URL of the web page hosting the content.
    FileSize         - The size of the file, in bytes.
    FileFormat       - One of avi, flash, mpeg, msmedia, quicktime
                       or realmedia.
    Duration         - The duration of the video file in seconds.
    Streaming        - Whether the video file is streaming or not.
 
The following attributes are optional, and might not be set:
 
    Height           - The height of the keyframe Yahoo! extracted
                       from the video, in pixels.
    Width            - The width of the keyframe Yahoo! extracted
                       from the video, in pixels.
    Channels         - Channels in the audio stream.
    Thumbnail        - The URL of the thumbnail file.
    Publisher        - The creator of the video file.
    Restrictions     - Provides any restrictions for this media
                       object. Restrictions include noframe and
                       noinline.
    Copyright        - The copyright owner.
 
If present, the Thumbnail value is in turn another dictionary, which will
have these keys:
 
    Url             - URL of the thumbnail.
    Height          - Height of the thumbnail in pixels (optional).
    Width           - Width of the thumbnail in pixels (optional).
 
 
Example:
    results = ws.parse_results(dom)
    for res in results:
        print "%s - %s bytes" % (res.Title, res.FileSize)
 
 
Method resolution order:
VideoSearch
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Thu Oct 27 10:47:24 PDT 2005'
__revision__ = '$Id: video.py,v 1.4 2005/10/27 18:07:59 zwoop Exp $'
__version__ = '$Revision: 1.4 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.dom.web.html0000644001174600001440000004415710571215015017542 0ustar leifusers Python: module yahoo.search.dom.web
 
 
yahoo.search.dom.web (version 1.5, Thu Oct 27 10:46:03 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/dom/web.py

DOM parser for Web search results
 
Implement a simple DOM parsers for the Yahoo Search Web Services
web search APIs. This provides parser for the following Web search
classes:
 
    WebSearch           - Web Search
    ContextSearch       - Web Search with a context added
    RelatedSuggestion   - Web Search Related Suggestion
    SpellingSuggestion  - Web Search Spelling Suggestion

 
Modules
       
yahoo.search.dom

 
Classes
       
yahoo.search.dom.DOMResultParser(yahoo.search.parser.ResultParser)
RelatedSuggestion
SpellingSuggestion
WebSearch

 
class RelatedSuggestion(yahoo.search.dom.DOMResultParser)
    RelatedSuggestion - DOM parser for Web Related Suggestions
 
Simple related suggestions web service, returning a list of the
candidate result strings. Note that the results from this service
is slightly different compared to the other services, since each
result can only be a string.
 
 
Method resolution order:
RelatedSuggestion
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
class SpellingSuggestion(yahoo.search.dom.DOMResultParser)
    SpellingSuggestion - DOM parser for Web Spelling Suggestions
 
Simple spell checking web service, there can be only zero or one
result from the query. Also note that the results from the search
are slightly different compared to the other services, the one
(possible) result is just simple string (not a dictionary).
 
 
Method resolution order:
SpellingSuggestion
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
class WebSearch(yahoo.search.dom.DOMResultParser)
    WebSearch - DOM parser for Web Search
 
Each result is a dictionary populated with the extracted data from the
XML results. The following keys are always available:
 
    Title            - The title of the web page.
    Summary          - Summary text associated with the web page.
    Url              - The URL for the web page.
    ClickUrl         - The URL for linking to the page.
 
The following attributes are optional, and might not be set:
 
    ModificationDate - The date the page was last modified, Unix time.
    MimeType         - The MIME type of the page.
    Cache            - The URL of the cached result, and its size.
 
If present, the Cache value is in turn another dictionary, which will
have the following keys:
 
    Url             - URL to cached data.
    Size            - Size of the cached entry, in bytes.
 
 
Example:
    results = ws.parse_results(dom)
    for res in results:
        if res.has_key('Cache'):
            print "Cache URL: ", res['Cache']['Url']
 
 
Method resolution order:
WebSearch
yahoo.search.dom.DOMResultParser
yahoo.search.parser.ResultParser
__builtin__.object

Methods inherited from yahoo.search.dom.DOMResultParser:
parse_results(self, dom_object)
This is a simple DOM parser for all Yahoo Search services. It
expects to find a top-level node named ResultSet. This is the main
entry point for the DOM parser, and it requires a properly con-
structed DOM object (e.g. using minidom).

Methods inherited from yahoo.search.parser.ResultParser:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)

Data descriptors inherited from yahoo.search.parser.ResultParser:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
firstResultPosition
The first result position
first_result_position
The first result position
results
The list of all results
service
The Search Web Service object for this results parser
totalResultsAvailable
Total number of results for the query
totalResultsReturned
The number of results returned
total_results_available
Total number of results for the query
total_results_returned
The number of results returned

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Thu Oct 27 10:46:03 PDT 2005'
__revision__ = '$Id: web.py,v 1.5 2005/10/27 18:07:59 zwoop Exp $'
__version__ = '$Revision: 1.5 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.factory.html0000644001174600001440000002146310671606267017667 0ustar leifusers Python: module yahoo.search.factory
 
 
yahoo.search.factory (version 1.11, Tue Sep 11 15:33:28 MDT 2007)
index
/home/leif/hack/pysearch/yahoo/search/factory.py

Search Factory - simple API to create search objects
 
This module implements a few convenience functions to make it easy and safe
to create search objects. This is not the most efficient way to use the web
services, but it's convenient. Future releases of the APIs will hopefully
also make this factory implementation less cumbersome.

 
Modules
       
yahoo.search.audio
yahoo.search.image
yahoo.search.local
yahoo.search.news
yahoo.search.site
yahoo.search.term
yahoo.search.video
yahoo.search.web

 
Functions
       
create_search(name, app_id, xml_parser=None, result_factory=None, debug_level=0, **args)
Create a Yahoo Web Services object, and configure it
 
This is a simple "factory" function to instantiate and configure
a Yahoo Web Services object. For example:
 
    app_id = "YahooDemo"
    srch = create_search("Web", app_id, query="Yahoo", results=4)
    if srch is not None:
        dom = srch.get_results()
 
The first argument is one of the following "classes" of searches:
 
    Web            - Web search
    Context        - Contextual Web search
    Related        - Web search Related Suggestions
    Spelling       - Web search Spelling Suggestions
 
    Video          - Video search
    Image          - Image search
    News           - News article search
    Local          - Local search
    Term           - Term extraction service
 
    Artist         - Find information on a musical performer
    Album          - Find information about albums
    Song           - Provide information about songs
    SongDownload   - Find links to various song providers of a song
    Podcast        - Search for a Podcast site/feed
 
    PageData       - Find all pages belonging to a domain
    InlinkData     - Show pages linking to a specific page
 
 
The second argument, app_id (or appid), is an application specific
identifier, provided by Yahoo. The web services will not accept any
requests without a proper AppID.
 
All other arguments must be valid named arguments, and the allowed
set of parameters depends on the specific class of search being
instantiated. See http://developer.yahoo.net/search/ for a more
comprehensive list and documentation of allowed parameters for all
types of searches.

 
Data
        SERVICES = {'album': (<class 'yahoo.search.audio.AlbumSearch'>, 'Search for a specific music album'), 'artist': (<class 'yahoo.search.audio.ArtistSearch'>, 'Information on a musical performer'), 'context': (<class 'yahoo.search.web.ContextSearch'>, 'Contextual Web Search'), 'image': (<class 'yahoo.search.image.ImageSearch'>, 'Image Search'), 'inlinkdata': (<class 'yahoo.search.site.InlinkData'>, 'Show pages linking to a specific page'), 'local': (<class 'yahoo.search.local.LocalSearch'>, 'Local Search'), 'news': (<class 'yahoo.search.news.NewsSearch'>, 'News Search'), 'pagedata': (<class 'yahoo.search.site.PageData'>, 'Find all pages belonging to a domain'), 'podcast': (<class 'yahoo.search.audio.PodcastSearch'>, 'Search for a Podcast site/feed'), 'related': (<class 'yahoo.search.web.RelatedSuggestion'>, 'Web Search Related Suggestion'), ...}
__author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Sep 11 15:33:28 MDT 2007'
__revision__ = '$Id: factory.py,v 1.11 2007/09/11 21:38:43 zwoop Exp $'
__version__ = '$Revision: 1.11 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.html0000644001174600001440000003554710671606264016226 0ustar leifusers Python: package yahoo.search
 
 
yahoo.search (version 1.19, Thu Jul 7 14:22:16 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/__init__.py

Yahoo Search Web Services
 
This module implements a set of classes and functions to work with the
Yahoo Search Web Services. All results from these services are properly
formatted XML, and this package facilitates for proper parsing of these
result sets. Some of the features include:
 
    * Extendandable API, with replaceable backend XML parsers, and
      I/O interface.
    * Type and value checking on search parameters, including
      automatic type conversion (when appropriate and possible)
    * Flexible return format, including DOM objects, or fully
      parsed result objects
 
 
You can either instantiate a search object directly, or use the factory
function create_search() from the factory module. The supported classes
of searches are:
    
    NewsSearch     - News article search
    VideoSearch    - Video and movie search
    ImageSearch    - Image search
    LocalSearch    - Local area search
 
    WebSearch           - Web search
    ContextSearch       - Web search with a context
    RelatedSuggestion   - Web search Related Suggestion
    SpellingSuggestion  - Web search Spelling Suggestion
 
    TermExtraction - Term Extraction service
 
    AlbumSearch    - Find information about albums
    ArtistSearch   - Information on a particular musical performer
    SongDownload   - Find links to various song providers of a song
    PodcastSearch  - Search for a Podcast site/feed
    SongSearch     - Provide information about songs
 
    PageData       - Shows a list of all pages belonging to a domain
    InlinkData     - Shows the pages from other sites linking to a page
 
 
The different sub-classes of search supports different sets of query
parameters. For details on all allowed parameters, please consult the
specific module documentation.
 
Each of these parameter is implemented as an attribute of each
respective class. For example, you can set parameters like:
 
    from yahoo.search.web import WebSearch
 
    app_id = "YahooDemo"
    srch = WebSearch(app_id)
    srch.query = "Leif Hedstrom"
    srch.results = 40
 
or, if you are using the factory function:
    
    from yahoo.search.factory import create_search
 
    app_id = "YahooDemo"
    srch = create_search("Web", app_id, query="Leif Hedstrom", results=40)
    if srch is not None:
        # srch object ready to use
        ...
    else:
        print "error"
 
or, the last alternative, a combination of the previous two:
 
    import yahoo.search.web
 
    app_id = "YahooDemo"
    srch = web.WebSearch(app_id, query="Leif Hedstrom", results=40)
 
To retrieve a certain parameter value, simply access it as any normal
attribute:
 
    print "Searched for ", srch.query
 
 
For more information on these parameters, and their allowed values, please
see the official Yahoo Search Services documentation available at
 
    http://developer.yahoo.net/
 
Once the webservice object has been created, you can retrieve a parsed
object (typically a DOM object) using the get_results() method:
 
    dom = srch.get_results()
 
This DOM object contains all results, and can be used as is. For easier
use of the results, you can use the built-in results factory, which will
traverse the entire DOM object, and create a list of results objects.
 
    results = srch.parse_results(dom)
 
or, by using the implicit call to get_results():
 
    results = srch.parse_results()
    
The default XML parser and results factories should be adequate for most
users, so use the parse_results() when possible. However, both the XML
parser and the results parser can easily be overriden. See the examples
below for details. More information about the DOM parsers are available
in the yahoo.search.dom module, and it's subclasses.
 
 
EXAMPLES:
 
This simple application will create a search object using the first
command line argument as the "type" (e.g. "web" or "news"), and all
subsequent arguments forms the query string:
 
    #!/usr/bin/python
 
    import sys
    from yahoo.search.factory import create_search
 
    service = sys.argv[1]
    query = " ".join(sys.argv[2:])
    app_id = "YahooDemo"
    srch = create_search(service, app_id, query=query, results=5)
    if srch is None:
        srch = create_search("Web", app_id, query=query, results=5)
 
    dom = srch.get_results()
    results = srch.parse_results(dom)
 
    for res in results:
        url = res.Url
        summary = res['Summary']
        print "%s -> %s" (summary, url)
 
 
The same example using the PyXML 4DOM parser:
 
    #!/usr/bin/python
 
    import sys
    from yahoo.search.factory import create_search
    from xml.dom.ext.reader import Sax2
 
    query = " ".join(sys.argv[2:])
    srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5)
    if srch is not None:
        reader = Sax2.Reader()
        srch.install_xml_parser(reader.fromStream)
        .
        .
        .
 
 
The last example will produce the same query, but uses an HTTP proxy
for the request:
 
    #!/usr/bin/python
 
    import sys
    from yahoo.search.factory import create_search
    import urllib2
 
    query = " ".join(sys.argv[2:])
    srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5)
 
    if srch is not None:
        proxy = urllib2.ProxyHandler({"http" : "http://octopus:3128"})
        opener = urllib2.build_opener(proxy)
        srch.install_opener(opener)
        .
        .
        .
 
 
You can obviously "mix and match" as necessary here. I'm using the
installer methods above for clarity, the APIs allows you to pass those
custom handlers as arguments as well (see the documentation below).

 
Package Contents
       
audio
debug
dom (package)
factory
image
local
news
parser
site
term
version
video
web
webservices

 
Data
        __all__ = ['web', 'news', 'video', 'image', 'local', 'term', 'audio', 'site']
__author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Thu Jul 7 14:22:16 PDT 2005'
__revision__ = '$Id: __init__.py,v 1.19 2007/09/11 21:38:43 zwoop Exp $'
__version__ = '$Revision: 1.19 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.image.html0000644001174600001440000006143510671606265017303 0ustar leifusers Python: module yahoo.search.image
 
 
yahoo.search.image (version 1.4, Tue Feb 27 14:51:16 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/image.py

yahoo.search.image - Image Search services module
 
This module implements the the Image Search web service, to do search
queries on various image formats. There is currently only one class
implemented, ImageSearch.
 
An application ID (appid) is always required when instantiating a search
object. Additional parameters are documented in the ImageSearch class.
 
Example:
 
    from yahoo.search.image import ImageSearch
 
    srch = ImageSearch(app_id="YahooDemo", query="Yahoo")
    srch.results = 10
 
    for res in srch.parse_results():
       print res.Thumbnail.Url

 
Modules
       
types
yahoo

 
Classes
       
yahoo.search._CommonSearch(yahoo.search._Search)
ImageSearch

 
class ImageSearch(yahoo.search._CommonSearch)
    ImageSearch - perform a Yahoo Image Search
 
This class implements the Image Search web service APIs. Allowed
parameters are:
 
    query        - The query to search for (UTF-8 encoded).
    type         - The kind of search to submit (all, any or phrase).
    results      - The number of results to return (1-50).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    type         - The kind of search to submit:
                      * "all" returns results with all query terms.
                      * "any" resturns results with one or more of the
                        query terms.
                      * "phrase" returns results containing the query
                        terms as a phrase.
    format       - Specifies the kind of image file to search for.
    adult_ok     - The service filters out adult content by default.
                   Enter a 1 to allow adult content.
    coloration   - The coloration type of the images (default, bw or
                   color).
    site         - A domain to restrict your searches to (e.g.
                   www.yahoo.com). You may submit up to 30 values
                   (e.g. ["www.yahoo.com", "www.cnn.com"]).
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Supported formats are
 
    any     - Any format
    bmp     - Bitmap (windows)
    gif     - GIF
    jpeg    - JPEG
    png     - PNG
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/image/V1/imageSearch.html
 
 
Method resolution order:
ImageSearch
yahoo.search._CommonSearch
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'imageSearch'
SERVICE = 'ImageSearchService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 14:51:16 MST 2007'
__revision__ = '$Id: image.py,v 1.4 2007/02/28 05:20:09 zwoop Exp $'
__version__ = '$Revision: 1.4 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.local.html0000644001174600001440000007115710671606265017315 0ustar leifusers Python: module yahoo.search.local
 
 
yahoo.search.local (version 1.4, Tue Feb 27 17:04:24 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/local.py

yahoo.search.local - Local Search services module
 
This module implements the the Local Search web service, to do search
queries on various local formats. There is currently only one class
implemented, LocalSearch.
 
An application ID (appid) is always required when instantiating a search
object. Additional parameters are documented in the LocalSearch class.
 
Example:
 
    from yahoo.search.local import LocalSearch
 
    srch = LocalSearch(app_id="YahooDemo", zip="94019", query="BevMo")
    srch.results = 1
 
    for res in srch.parse_results():
       print res.MapUrl

 
Modules
       
types
yahoo

 
Classes
       
yahoo.search._BasicSearch(yahoo.search._Search)
LocalSearch

 
class LocalSearch(yahoo.search._BasicSearch)
    LocalSearch - perform a Yahoo Local Search
 
This class implements the Local Search web service APIs. Allowed
parameters are:
 
    query         - The query to search for. Using a query of "*"
                    returns all values that match other criteria in the
                    search (category, radius, and so on).
    listing_id    - The id associated with a specific business listing.
                    It corresponds with the id attribute of Result
                    entities. At least one of query or listing id must
                    be specified.
    results       - The number of results to return (1-20).
    start         - The starting result position to return (1-based).
                    The finishing position (start + results - 1) cannot
                    exceed 1000.
    sort          - Sorts the results by the chosen criteria.
    radius        - How far from the specified location to search for
                    the query terms.
    street        - Street name. The number is optional.
    city          - City name.
    state         - The United States state. You can spell out the
                    full state name or you can use the two-letter
                    abbreviation.
    zip           - The five-digit zip code, or the five-digit code
                    plus four-digit extension.
    location      - Free form field for location (see below).
    latitude      - Latitude of the starting location (-90.0 - 90.0).
    longitude     - Longitude of the starting location (-180.0 - 180.0).
    category      - The id of a category to search in. This id
                    corresponds to the id attribute of the Category
                    entity. If you specify multiple categories, results
                    are taken from entries that appear in all of the
                    specified categories.
    omit_category  - The id of a category to omit results from. Multiple
                     categories may be omitted, and a result will not be
                     returned if it appears in any of the specified
                     categories.
    minimum_rating - The minimum average rating (on a five point scale)
                     for a result. If this is specified, no results
                     without ratings will be returned.
    output         - The format for the output result. If json or php is
                     requested, the result is not XML parseable, so we
                     will simply return the "raw" string.
    callback       - The name of the callback function to wrap around
                     the JSON data.
 
 
If both latitude and longitude are specified, they will take priority
over all other location data. If only one of latitude or longitude is
specified, both will be ignored.
 
The sort parameter is one of
 
    relevance
    title
    distance
    rating
 
The free text of the location parameter can hold any of
 
    * city, state
    * city,state, zip
    * zip
    * street, city, state
    * street, city, state, zip
    * street, zip
 
If location is specified, it will take priority over the individual
fields in determining the location for the query. City, state and zip
will be ignored.
                    
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/search/local/V3/localSearch.html
 
 
Method resolution order:
LocalSearch
yahoo.search._BasicSearch
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'localSearch'
SERVER = 'local.yahooapis.com'
SERVICE = 'LocalSearchService'
VERSION = 'V3'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 17:04:24 MST 2007'
__revision__ = '$Id: local.py,v 1.4 2007/02/28 05:20:09 zwoop Exp $'
__version__ = '$Revision: 1.4 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.myweb.html0000644001174600001440000024065410571215011017326 0ustar leifusers Python: module yahoo.search.myweb
 
 
yahoo.search.myweb (version 1.5, Tue Feb 27 17:06:45 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/myweb.py

yahoo.search.myweb - Yahoo Search MyWeb Web Services
 
This module implements a set of classes and functions to work with the
Yahoo Search MyWeb Web Services. The supported classes of MyWeb
and MyWeb2 searches are:
 
    ListFolders    - List (public) MyWeb folders
    ListUrls       - List the URLs in a MyWeb folder
 
    UrlSearch      - Search for URLs with particular tags
    TagSearch      - Search for tags associated with URL or user
    RelatedTags    - Find tags that appear together on URLs
 
 
The various sub-classes of MyWeb Search supports different sets of query
parameters. They all require an application ID parameter (app_id). The
following tables describes all other allowed parameters for each of the
supported services:
 
                List Folders  List URLs
                ------------  ---------
    folder           .           [X]
    yahooid         [X]          [X]
    sort             .           [X]
    sort_order       .           [X]
    results         [X]          [X]
    start           [X]          [X]
 
 
 
MyWeb2 also adds the following services:
 
                URL Search  Tag Search  Related Tags
                ----------  ----------  ------------
    tag             [X]         .           [X]
    url              .         [X]           .
    yahooid         [X]        [X]          [X]
    sort            [X]        [X]          [X]
    reverse_sort    [X]        [X]          [X]
    results         [X]        [X]          [X]
    start           [X]        [X]          [X]
 
 
Each of these parameter is implemented as an attribute of each
respective class. For example, you can set parameters like:
 
    from yahoo.search.myweb import ListFolders
 
    app_id = "YahooDemo"
    srch = ListFolders(app_id)
    srch.yahooid = "some_valid_yahoo_id"
    srch.results = 40

 
Modules
       
types
yahoo

 
Classes
       
_MyWeb(yahoo.search._Search)
ListFolders
ListUrls
RelatedTags
TagSearch
UrlSearch

 
class ListFolders(_MyWeb)
    ListFolders - Retrieving public folders
 
This class implements the My Web service to retrieve public folders.
Allowed parameters are:
 
    yahooid      - The Yahoo! user who owns the folder being accessed.
    results      - The number of results to return (1-50).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/myweb/V1/listFolders.html
 
 
Method resolution order:
ListFolders
_MyWeb
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'listFolders'
SERVICE = 'MyWebService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Data descriptors inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
appid
Application ID (issued by Yahoo)
cc_licenses
List of all supported Creative Commons licenses
countries
List of all supported county codes
debug_level
Set and modify the debug level
languages
List of all supported languages
regions
List of all supported region codes
subscriptions
List of all supported premium subscriptions
svc_name
Descriptive name of the service
svc_protocol
Service protocol (e.g. HTTP)
svc_server
Service server name or IP
svc_service
Service path
svc_version
Service version string

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data descriptors inherited from yahoo.search.debug.Debuggable:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class ListUrls(_MyWeb)
    ListUrls - Retrieving public URL stores
 
This class implements the My Web service to retrieve URLs from a
public folder. Allowed parameters are:
 
    folder       - The folder to retreive queries from. The folder
                   must be set to "Public" in order to be accessed.
    yahooid      - The Yahoo! user who owns the folder being accessed.
    sort         - The field by which the results should be sorted.
    sort_order   - Ascending or descending sort order, "asc" which is
                   the default, or "desc".
    results      - The number of results to return (1-50).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
The sort parameter can take one of the following values:
 
    storedate  - Date stored (default)
    title      - Title
    summary    - Summary
    note       - Note
    url        - URL
    
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/myweb/V1/listUrls.html
 
 
Method resolution order:
ListUrls
_MyWeb
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'listUrls'
SERVICE = 'MyWebService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Data descriptors inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
appid
Application ID (issued by Yahoo)
cc_licenses
List of all supported Creative Commons licenses
countries
List of all supported county codes
debug_level
Set and modify the debug level
languages
List of all supported languages
regions
List of all supported region codes
subscriptions
List of all supported premium subscriptions
svc_name
Descriptive name of the service
svc_protocol
Service protocol (e.g. HTTP)
svc_server
Service server name or IP
svc_service
Service path
svc_version
Service version string

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data descriptors inherited from yahoo.search.debug.Debuggable:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class RelatedTags(_MyWeb)
    RelatedTags - Find tags that appear together on URLs
 
This class implements a MyWeb2 service which allows you to find tags that
appear together on URLs. For example, if a URL is tagger with 'yahoo' and
'music', a search for the tag 'yahoo' will return 'music' as a related
tag.
 
    tag          - The tag to search for. Multiple tags may be
                   specified (e.g. ["tag1", "tag2"]).
    yahooid      - The Yahoo! user who owns the folder being accessed.
    sort         - The field by which the results should be sorted. Options
                   are popularity (default), tag or date.
    reverse_sort - If set to 1, reverses the sort order. This has no effect
                   on popularity searches.
    results      - The number of results to return (1-50).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/myweb/V1/relatedTags.html
 
 
Method resolution order:
RelatedTags
_MyWeb
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'relatedTags'
SERVICE = 'MyWebService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Data descriptors inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
appid
Application ID (issued by Yahoo)
cc_licenses
List of all supported Creative Commons licenses
countries
List of all supported county codes
debug_level
Set and modify the debug level
languages
List of all supported languages
regions
List of all supported region codes
subscriptions
List of all supported premium subscriptions
svc_name
Descriptive name of the service
svc_protocol
Service protocol (e.g. HTTP)
svc_server
Service server name or IP
svc_service
Service path
svc_version
Service version string

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data descriptors inherited from yahoo.search.debug.Debuggable:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class TagSearch(_MyWeb)
    TagSearch - Search for tags by URL and/or by user
 
This class implements a MyWeb2 service which allows you to find tags that
have been associated with URLs by MyWeb 2.0 users. Allowed parameters are:
 
    url          - If specified, only returns tags associated with this url.
    yahooid      - The Yahoo! user who owns the folder being accessed.
    sort         - The field by which the results should be sorted. Options
                   are popularity (default), tag or date.
    reverse_sort - If set to 1, reverses the sort order. This has no effect
                   on popularity searches.
    results      - The number of results to return (1-50).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/myweb/V1/tagSearch.html
 
 
Method resolution order:
TagSearch
_MyWeb
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'tagSearch'
SERVICE = 'MyWebService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Data descriptors inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
appid
Application ID (issued by Yahoo)
cc_licenses
List of all supported Creative Commons licenses
countries
List of all supported county codes
debug_level
Set and modify the debug level
languages
List of all supported languages
regions
List of all supported region codes
subscriptions
List of all supported premium subscriptions
svc_name
Descriptive name of the service
svc_protocol
Service protocol (e.g. HTTP)
svc_server
Service server name or IP
svc_service
Service path
svc_version
Service version string

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data descriptors inherited from yahoo.search.debug.Debuggable:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class UrlSearch(_MyWeb)
    UrlSearch - Search for URLs with particular tags
 
This class implements the MyWeb2 service to search for URLs that have
been tagged by particular tags. Allowed parameters are:
 
    tag          - The tag to search for. Multiple tags may be
                   specified (e.g. ["tag1", "tag2"]).
    yahooid      - The Yahoo! user who owns the folder being accessed.
    sort         - The field by which the results should be sorted.
                   date sorts most-recent-first, title and url are
                   sorted alphabetically.
    reverse_sort - If set to 1, reverses the sort order.
    results      - The number of results to return (1-50).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/myweb/V1/urlSearch.html
 
 
Method resolution order:
UrlSearch
_MyWeb
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'urlSearch'
SERVICE = 'MyWebService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Data descriptors inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
appid
Application ID (issued by Yahoo)
cc_licenses
List of all supported Creative Commons licenses
countries
List of all supported county codes
debug_level
Set and modify the debug level
languages
List of all supported languages
regions
List of all supported region codes
subscriptions
List of all supported premium subscriptions
svc_name
Descriptive name of the service
svc_protocol
Service protocol (e.g. HTTP)
svc_server
Service server name or IP
svc_service
Service path
svc_version
Service version string

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data descriptors inherited from yahoo.search.debug.Debuggable:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 17:06:45 MST 2007'
__revision__ = '$Id: myweb.py,v 1.5 2007/02/28 05:20:09 zwoop Exp $'
__version__ = '$Revision: 1.5 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.news.html0000644001174600001440000005727110671606265017200 0ustar leifusers Python: module yahoo.search.news
 
 
yahoo.search.news (version 1.4, Tue Feb 27 17:20:45 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/news.py

yahoo.search.news - News Search service module
 
This module implements the News Search web services, searching news
articles. There is currently only one class implemented, NewsSearch.
 
An application ID (appid) is always required when instantiating a search
object. Additional parameters are documented in the NewsSearch class.
 
Example:
 
    from yahoo.search.news import NewsSearch
 
    srch = NewsSearch(app_id="YahooDemo", query="Yahoo")
    srch.results = 10
 
    for res in srch.parse_results():
       print res.NewsSource

 
Modules
       
types
yahoo

 
Classes
       
yahoo.search._BasicSearch(yahoo.search._Search)
NewsSearch

 
class NewsSearch(yahoo.search._BasicSearch)
    NewsSearch - perform a Yahoo News Search
 
This class implements the News Search web service APIs. Allowed
parameters are:
 
    query        - The query to search for.
    type         - The kind of search to submit:
                     * "all" returns results with all query terms.
                     * "any" resturns results with one or more of the
                       query terms.
                     * "phrase" returns results containing the query
                      terms as a phrase.
    results      - The number of results to return (1-50).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    sort         - Sort articles by relevance ('rank') or most-recent
                   ('date'). Default is by relevance.
    language     - The language the results are written in.
    site         - A domain to restrict your searches to (e.g.
                   www.yahoo.com). You may submit up to 30 values
                   (e.g. ["www.yahoo.com", "www.cnn.com"]).
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/news/V1/newsSearch.html
 
 
Method resolution order:
NewsSearch
yahoo.search._BasicSearch
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'newsSearch'
SERVICE = 'NewsSearchService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 17:20:45 MST 2007'
__revision__ = '$Id: news.py,v 1.4 2007/02/28 05:20:09 zwoop Exp $'
__version__ = '$Revision: 1.4 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.parser.html0000644001174600001440000005544510671606266017522 0ustar leifusers Python: module yahoo.search.parser
 
 
yahoo.search.parser (version 1.4, Wed Oct 26 11:24:50 PDT 2005)
index
/home/leif/hack/pysearch/yahoo/search/parser.py

Base class for search results parsing
 
This package implements the interface and base class that should be
used for all parsers of the web results. It is used by the DOM parsers
that we provide as defaults.

 
Classes
       
__builtin__.dict(__builtin__.object)
ResultDict
__builtin__.object
ResultParser
exceptions.Exception
Error
ClassError
XMLError

 
class ClassError(Error)
    This can only occur if the APIs aren't installed or configured
properly. If it happens, please contact the author.
 
 
Method resolution order:
ClassError
Error
exceptions.Exception

Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class Error(exceptions.Exception)
    Base class for all Yahoo DOM Parser exceptions.
 
  Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class ResultDict(__builtin__.dict)
    ResultDict - Simple class to wrap the results
 
 
Method resolution order:
ResultDict
__builtin__.dict
__builtin__.object

Methods defined here:
__getattr__(self, key)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'ResultDict' objects>
list of weak references to the object (if defined)

Methods inherited from __builtin__.dict:
__cmp__(...)
x.__cmp__(y) <==> cmp(x,y)
__contains__(...)
D.__contains__(k) -> True if D has a key k, else False
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
clear(...)
D.clear() -> None.  Remove all items from D.
copy(...)
D.copy() -> a shallow copy of D
get(...)
D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
has_key(...)
D.has_key(k) -> True if D has a key k, else False
items(...)
D.items() -> list of D's (key, value) pairs, as 2-tuples
iteritems(...)
D.iteritems() -> an iterator over the (key, value) items of D
iterkeys(...)
D.iterkeys() -> an iterator over the keys of D
itervalues(...)
D.itervalues() -> an iterator over the values of D
keys(...)
D.keys() -> list of D's keys
pop(...)
D.pop(k[,d]) -> v, remove specified key and return the corresponding value
If key is not found, d is returned if given, otherwise KeyError is raised
popitem(...)
D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty
setdefault(...)
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
update(...)
D.update(E, **F) -> None.  Update D from E and F: for k in E: D[k] = E[k]
(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]
values(...)
D.values() -> list of D's values

Data and other attributes inherited from __builtin__.dict:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T
fromkeys = <built-in method fromkeys of type object>
dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.

 
class ResultParser(__builtin__.object)
    Yahoo Search Web Service Results - base class
 
This is the base class for all Yahoo Search Web Service result parsers.
If you build your own result parser (e.g. non-DOM based), please sub-
class ResultParser.  The following attributes are always available:
 
    total_results_available
    total_results_returned
    first_result_position
 
    results
 
 
Results are a list of dictionaries, which can be a custom class as
required. An interator generator is provided for easy access to the
list of results. For example, to iterate over all results, you would do
something like:
 
    dom = ws.get_results()
    results = ws.parse_results(dom)
    dom.unlink()
 
    for res in results:
        print res['Url']
        print res.Summary
 
 
As you can see, each result is a customizable dictionary. The default
results dict supports accessing each key as a "property", like the
above example (res.Summary).
 
You can also get the list of results directly, using the results
attribute. An optional res_dict argument can be used to provide an
alternative dictionary implementation to use for the results.
 
  Methods defined here:
__init__(self, service, res_dict=<class 'yahoo.search.parser.ResultDict'>)
__iter__(self)
parse_results(self, result_set)
Parse the results.

Properties defined here:
firstResultPosition
The first result position
get = _get_first_result_position(self)
Get the first result position.
first_result_position
The first result position
get = _get_first_result_position(self)
Get the first result position.
results
The list of all results
get = _get_results(self)
Get the results.
service
The Search Web Service object for this results parser
get = _get_service(self)
Get the service for this DOM parser.
set = _set_service(self, service)
Set the service for this DOM parser.
totalResultsAvailable
Total number of results for the query
get = _get_total_results_available(self)
Get the total number of results for the query.
totalResultsReturned
The number of results returned
get = _get_total_results_returned(self)
Get the number of results returned.
total_results_available
Total number of results for the query
get = _get_total_results_available(self)
Get the total number of results for the query.
total_results_returned
The number of results returned
get = _get_total_results_returned(self)
Get the number of results returned.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'ResultParser' objects>
list of weak references to the object (if defined)

 
class XMLError(Error)
    This exception can occur if, and only if, Yahoo returns malformed
XML results.
 
 
Method resolution order:
XMLError
Error
exceptions.Exception

Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
Functions
       
string_to_bool(string)
Convert a string to a boolean value

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Wed Oct 26 11:24:50 PDT 2005'
__revision__ = '$Id: parser.py,v 1.4 2005/10/26 20:32:27 zwoop Exp $'
__version__ = '$Revision: 1.4 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.site.html0000644001174600001440000017402510671606266017166 0ustar leifusers Python: module yahoo.search.site
 
 
yahoo.search.site (version 1.3, Tue Feb 27 21:54:42 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/site.py

yahoo.search.site - Site Explorer services module
 
This module implements the Site Explorer web services, which can be used
gain a unique perspective on your online presence. The supported classes
of site explorer are:
    
    PageData      - Shows a list of all pages belonging to a domain
    InlinkData    - Shows the pages from other sites linking in to a page
 
    Update Notification  - Notify Yahoo! of changes to your site
 
 
An application ID (appid) is always required when instantiating a search
object. In addition, each search class takes different set of parameters,
as defined by this table
 
                  PageData  InlinkData  Update Notification
                  --------  ----------  -------------------
    query          [X]         [X]              .
    results        [X]         [X]              .
    start          [X]         [X]              .
 
    domain_only    [X]          .               .
    entire_site     .          [X]              .
    omit_inlinks    .          [X]              .
 
    url             .           .              [X]
 
    output         [X]         [X]              .
    callback       [X]         [X]              .
 
 
Each of these parameter is implemented as an attribute of each
respective class. For example, you can set parameters like:
 
    from yahoo.search.site import PageData
 
    srch = PageData(appid="YahooDemo")
    srch.query = "http://www.ogre.com"
    srch.results = 75
 
    for res in srch.parse_results():
       print res.Url

 
Modules
       
types
yahoo

 
Classes
       
yahoo.search._BasicSearch(yahoo.search._Search)
InlinkData
PageData
yahoo.search._Search(yahoo.search.debug.Debuggable, __builtin__.object)
UpdateNotification

 
class InlinkData(yahoo.search._BasicSearch)
    InlinkData - discover what pages link to your website
 
This class implements the Inlink Data web service APIs. Allowed
parameters are:
 
    query        - The query to search for (UTF-8 encoded).
    results      - The number of results to return (1-100).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    entire_site  - Specifies whether to provide results for the entire
                   site, or just the page referenced by the query. If the
                   query is not a domain URL (i.e. it contains a path,
                   such as http://smallbusiness.yahoo.com/webhosting/),
                   this parameter has no effect. Allowed values are
                   0 (default) or 1.
    omit_inlinks - If specified, inlinks will not be returned if they
                   are from pages in the same domain/subdomain as the
                   requested page. Allowed values are domain or
                   subdomain.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/search/siteexplorer/V1/inlinkData.html
 
 
Method resolution order:
InlinkData
yahoo.search._BasicSearch
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'inlinkData'
SERVICE = 'SiteExplorerService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
class PageData(yahoo.search._BasicSearch)
    PageData - discover what is in the Yahoo! index
 
This class implements the Page Data web service APIs. Allowed
parameters are:
 
    query        - The query to search for (UTF-8 encoded).
    results      - The number of results to return (1-100).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    domain_only  - Specifies whether to provide results for all
                   subdomains (such as http://search.yahoo.com for
                   http://www.yahoo.com) of the domain query, or just the
                   specifically requested domain. If the query is not a
                   domain URL (i.e. it contains path information, such as
                   http://smallbusiness.yahoo.com/webhosting/), this
                   parameter has no effect. Allowed values are 0 (default)
                   or 1.
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/search/siteexplorer/V1/pageData.html
 
 
Method resolution order:
PageData
yahoo.search._BasicSearch
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'pageData'
SERVICE = 'SiteExplorerService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
class UpdateNotification(yahoo.search._Search)
    UpdateNotification - Tell the Yahoo! to index your URLs
 
This class implements the Update Notification web service APIs. Allowed
parameters are:
 
    url        - The URL to submit
 
 
Full documentation for this service is available at:
 
 http://developer.yahoo.com/search/siteexplorer/V1/updateNotification.html
 
 
Method resolution order:
UpdateNotification
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'updateNotification'
SERVICE = 'SiteExplorerService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 21:54:42 MST 2007'
__revision__ = '$Id: site.py,v 1.3 2007/02/28 05:20:09 zwoop Exp $'
__version__ = '$Revision: 1.3 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.term.html0000644001174600001440000005357110671606266017173 0ustar leifusers Python: module yahoo.search.term
 
 
yahoo.search.term (version 1.5, Tue Feb 27 14:26:00 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/term.py

yahoo.search.term - Term Extraction web services module
 
This module implements the the Term Extraction web service, to extract
significant words and phrases from a larger context. There is currently
only one class implemented, TermExtraction.
 
An application ID (appid) is always required when instantiating a search
object. Additional parameters are documented in the TermExtraction class.
Example:
 
    from yahoo.search.term import TermExtraction
 
    srch = TermExtraction(app_id="YahooDemo", query="Yahoo")
    srch.context = "portal news sports mail messenger"
 
    for res in srch.parse_results():
       print res

 
Modules
       
types
yahoo

 
Classes
       
yahoo.search._Search(yahoo.search.debug.Debuggable, __builtin__.object)
TermExtraction

 
class TermExtraction(yahoo.search._Search)
    TermExtraction - Extract words or phrases from a larger content
 
This class implements the Web Search Spelling Suggestion web service
APIs. The only allowed parameter is:
 
    context      - The context to extract terms from (UTF-8 encoded)
    query        - An optional query to help with the extraction
                   process
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
The Term Extraction service provides a list of significant words or
phrases extracted from a larger content. It is one of the technologies
used in Y!Q. Full documentation for this service is available at:
 
    http://developer.yahoo.net/content/V1/termExtraction.html
 
 
Method resolution order:
TermExtraction
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
METHOD = 'POST'
NAME = 'termExtraction'
SERVICE = 'ContentAnalysisService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 14:26:00 MST 2007'
__revision__ = '$Id: term.py,v 1.5 2007/02/28 05:20:09 zwoop Exp $'
__version__ = '$Revision: 1.5 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.version.html0000644001174600001440000000453610671606270017701 0ustar leifusers Python: module yahoo.search.version
 
 
yahoo.search.version (version 1.12, Tue Feb 27 22:22:37 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/version.py

yahoo.search.version - Version information

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 22:22:37 MST 2007'
__revision__ = '$Id: version.py,v 1.12 2007/02/28 05:22:43 zwoop Exp $'
__version__ = '$Revision: 1.12 $'
author = 'Leif Hedstrom <leif@ogre.com>'
authorMail = 'leif@ogre.com'
authorName = 'Leif Hedstrom'
credits = '- The entire Yahoo search team, of course.\n'
maintainerMail = 'leif@ogre.com'
maintainerName = 'Leif Hedstrom'
version = '3.0'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.video.html0000644001174600001440000006102710671606265017324 0ustar leifusers Python: module yahoo.search.video
 
 
yahoo.search.video (version 1.6, Tue Feb 27 21:13:43 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/video.py

yahoo.search.video - Video Search services module
 
This module implements the the Video Search web service, to do search
queries on various video formats. There is currently only one class
implemented, VideoSearch.
 
An application ID (appid) is always required when instantiating a search
object. Additional parameters are documented in the VideoSearch class.
 
Example:
 
    from yahoo.search.video import VideoSearch
 
    srch = VideoSearch(app_id="YahooDemo", query="Yahoo", results=10)
    for res in srch.parse_results():
        print res.Title

 
Modules
       
types
yahoo

 
Classes
       
yahoo.search._CommonSearch(yahoo.search._Search)
VideoSearch

 
class VideoSearch(yahoo.search._CommonSearch)
    VideoSearch - perform a Yahoo Video Search
 
This class implements the Video Search web service APIs. Allowed
parameters are:
 
    query        - The query to search for (UTF-8 encoded).
    type         - The kind of search to submit:
                      * "all" returns results with all query terms.
                      * "any" resturns results with one or more of the
                        query terms.
                      * "phrase" returns results containing the query
                        terms as a phrase.
    results      - The number of results to return (1-50).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    format       - Specifies the kind of video file to search for.
    adult_ok     - The service filters out adult content by default.
                   Enter a 1 to allow adult content.
    site         - A domain to restrict your searches to (e.g.
                   www.yahoo.com). You may submit up to 30 values
                   (e.g. ["www.yahoo.com", "www.cnn.com"]).
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Supported formats are
 
    any         - Match all formats
    avi         - AVI
    flash       - Flash
    mpeg        - MPEG
    msmedia     - Microsoft Media
    quicktime   - Apple Quicktime
    realmedia   - Realmedia
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/video/V1/videoSearch.html
 
 
Method resolution order:
VideoSearch
yahoo.search._CommonSearch
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'videoSearch'
SERVICE = 'VideoSearchService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Feb 27 21:13:43 MST 2007'
__revision__ = '$Id: video.py,v 1.6 2007/02/28 05:20:11 zwoop Exp $'
__version__ = '$Revision: 1.6 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.web.html0000644001174600001440000025601110671606265016772 0ustar leifusers Python: module yahoo.search.web
 
 
yahoo.search.web (version 1.10, Sun Feb 25 21:47:52 MST 2007)
index
/home/leif/hack/pysearch/yahoo/search/web.py

yahoo.search.web - Web Search services module
 
This module implements the Web Search web services, searching web content.
The supported classes of web searches are:
    
    WebSearch           - Web Search
    ContextSearch       - Web Search with a context added
    RelatedSuggestion   - Web Search Related Suggestion
    SpellingSuggestion  - Web Search Spelling Suggestion
 
An application ID (appid) is always required when instantiating a search
object. In addition, each search class takes different set of parameters,
as defined by this table
 
                 Web   Context  Related  Spelling
                -----  -------  -------  --------
    query        [X]     [X]      [X]       [X]
    region       [X]      .        .         .
    context       .      [X]       .         .
    type         [X]     [X]       .         .
    results      [X]     [X]      [X]        .
    start        [X]     [X]       .         .
 
    format       [X]     [X]       .         .
    adult_ok     [X]     [X]       .         .
    similar_ok   [X]     [X]       .         .
    language     [X]     [X]       .         .
    country      [X]     [X]       .         .
    site         [X]      .        .         .
    subscription [X]      .        .         .
 
    output       [X]     [X]      [X]       [X]
    callback     [X]     [X]      [X]       [X]
 
 
Each of these parameter is implemented as an attribute of each
respective class. For example, you can set parameters like:
 
    from yahoo.search.web import WebSearch
 
    srch = WebSearch(app_id="YahooDemo")
    srch.query = "Leif Hedstrom"
    srch.results = 40
 
    for res in srch.parse_results():
       print res.Url

 
Modules
       
types
yahoo

 
Classes
       
yahoo.search._CommonSearch(yahoo.search._Search)
ContextSearch
WebSearch
yahoo.search._Search(yahoo.search.debug.Debuggable, __builtin__.object)
RelatedSuggestion
SpellingSuggestion

 
class ContextSearch(yahoo.search._CommonSearch)
    ContextSearch - perform a Yahoo Web Search with a context
 
This class implements the Contextual Web Search service APIs, which is
very similar to a regular web search. Allowed parameters are:
 
    query        - The query to search for (UTF-8 encoded).
    context      - The context to extract meaning from (UTF-8 encoded).
    type         - The kind of search to submit (all, any or phrase).
                      * all returns results with all query terms.
                      * any resturns results with one or more of the
                        query terms.
                      * phrase returnes results containing the query
                        terms as a phrase.
    results      - The number of results to return (1-100).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    format       - Specifies the kind of web file to search for.
    adult_ok     - The service filters out adult content by default.
                   Enter a 1 to allow adult content.
    similar_ok   - Specifies whether to allow multiple results with
                   similar content. Enter a 1 to allow similar content.
    language     - The language the results are written in.
    country      - The country code for the country the website is
                   located in.
    license      - The Creative Commons license that the contents are
                   licensed under. You may submit multiple values (e.g.
                   license=cc_commercial&license=cc_modifiable).
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
    
 
Supported formats are
 
    html      - Regular HTML / XHTML
    msword    - Microsoft Word
    pdf       - Adobe PDF
    ppt       - Microsoft PowerPoint
    rss       - RSS feed
    txt       - Text file
    xls       - Microsft Excel
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/web/V1/contextSearch.html
 
 
Method resolution order:
ContextSearch
yahoo.search._CommonSearch
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
METHOD = 'POST'
NAME = 'contextSearch'
SERVICE = 'WebSearchService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
class RelatedSuggestion(yahoo.search._Search)
    RelatedSuggestion - perform a Yahoo Web Related Suggestions search
 
This class implements the Web Search Related Suggestion web service
APIs. The only allowed parameters are:
 
    query        - The query to get related searches from
    results      - The number of results to return (1-50)
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/web/V1/relatedSuggestion.html
 
 
Method resolution order:
RelatedSuggestion
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'relatedSuggestion'
SERVICE = 'WebSearchService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
class SpellingSuggestion(yahoo.search._Search)
    SpellingSuggestion - perform a Yahoo Web Spelling Suggestion search
 
This class implements the Web Search Spelling Suggestion web service
APIs. The only allowed parameter is:
 
    query        - The query to get spelling suggestions for
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/web/V1/spellingSuggestion.html
 
 
Method resolution order:
SpellingSuggestion
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'spellingSuggestion'
SERVICE = 'WebSearchService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
class WebSearch(yahoo.search._CommonSearch)
    WebSearch - perform a Yahoo Web Search
 
This class implements the Web Search web service APIs. Allowed
parameters are:
 
    query        - The query to search for (UTF-8 encoded).
    region       - The regional search engine on which the service
                   performs the search. For example, region=uk will give
                   you the search engine at uk.search.yahoo.com.
    type         - The kind of search to submit (all, any or phrase)
                      * all returns results with all query terms.
                      * any resturns results with one or more of the
                        query terms.
                      * phrase returns results containing the query
                        terms as a phrase.
    results      - The number of results to return (1-100).
    start        - The starting result position to return (1-based).
                   The finishing position (start + results - 1) cannot
                   exceed 1000.
    format       - Specifies the kind of web file to search for.
    adult_ok     - The service filters out adult content by default.
                   Enter a 1 to allow adult content.
    similar_ok   - Specifies whether to allow multiple results with
                   similar content. Enter a 1 to allow similar content
    language     - The language the results are written in.
    country      - The country code for the country the website is
                   located in.
    site         - A domain to restrict your searches to (e.g.
                   www.yahoo.com). You may submit up to 30 values
                   (e.g. ["www.yahoo.com", "www.cnn.com"]).
    subscription - Any subscriptions to premium content that should
                   also be searched. You may submit multiple values.
    license      - The Creative Commons license that the contents are
                   licensed under. You may submit multiple values (e.g.
                   [cc_commercial, cc_modifiable] ).
    output       - The format for the output result. If json or php is
                   requested, the result is not XML parseable, so we
                   will simply return the "raw" string.
    callback     - The name of the callback function to wrap around
                   the JSON data.
 
Supported values for 'format' are
 
    html      - Regular HTML / XHTML
    msword    - Microsoft Word
    pdf       - Adobe PDF
    ppt       - Microsoft PowerPoint
    rss       - RSS feed
    txt       - Text file
    xls       - Microsft Excel
 
 
Full documentation for this service is available at:
 
    http://developer.yahoo.net/web/V1/webSearch.html
 
 
Method resolution order:
WebSearch
yahoo.search._CommonSearch
yahoo.search._Search
yahoo.search.debug.Debuggable
__builtin__.object

Data and other attributes defined here:
NAME = 'webSearch'
SERVICE = 'WebSearchService'

Methods inherited from yahoo.search._Search:
__getattr__(self, name)
__init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args)
The app_id is a required argument, the Yahoo search services will
not accept requests without a proper app_id. A valid app_id is a
combination of 8 - 40 characters, matching the regexp
 
    "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\@]{8,40}$"
 
Please visit http://developer.yahoo.net/search/ to request an App ID
for your own software or application.
    
Four optional arguments can also be passed to the constructor:
 
    opener         - Opener for urllib2
    xml_parser     - Function to parse XML (default: minidom)
    result_factory - Result factory class (default: none)
    debug_devel    - Debug level (if any)
 
All other "named" arguments are passed into as a dictionary to the
set_params() method.
 
The result factory is specific to the particular web service used,
e.g. the different Yahoo Search services will each implement their
own factory class.
 
Both of these settings can be controlled via their respective
install method (see below).
__setattr__(self, name, value)
# Implement the attribute handlers, to avoid confusion
encode_params(self)
URL encode the list of parameter values.
get_param(self, param)
Get the value of a query parameter, or the default value if unset
get_results(self, stream=None, xml_parser=None, close=True)
Read the stream (if provided) and either return the raw XML, or
send the data to the provided XML parser for further processing.
If no stream is provided, it will call the open() method using the
default opener. The stream will be closed upon return from this
method, unless the close=False is passed as an argument.
get_url(self, with_params=True)
Return the URL for this request object
get_valid_params(self)
Return a list of all valid parameters for this search
install_opener(self, opener)
Install a URL opener (for use with urllib2), overriding the
default opener. This is rarely required.
install_result_factory(self, result_factory)
Install a python class (not an instance!) that should be used as a
factory for creating result(s) objects.
install_xml_parser(self, xml_parser)
Install an XML parser that will be used for all results for this
object. The parser is expected to "read" the data from the supplied
stream argument. To uninstall the parser (e.g. to make sure we
return raw XML data) simply call this method with an argument of
None.
missing_params(self)
Validate that the search object is propertly setup with all
required parameters etc. This is called automatically before a
search is actually performed, but you can also call it manually
if desired. It will return a list of zero or more paramters that
are missing.
open(self, opener=None, retries=2)
Open a connection to the webservice server, and request the URL.
The return value is a "stream", which can be read calling the
read(), readline() or readlines() methods. If you override this
method, please make sure to call the missing_params() method before
you try to send a request to the Web server.
parse_results(self, xml=None)
Get the result from the request, and instantiate the appropriate
result class. This class will be populated with all the data from
the XML object.
reset(self)
Reset all the parameter values for the object instance.
set_param(self, param, value)
Set the value of a query parameter
set_params(self, args)
Set one or several query parameters from a dictionary

Properties inherited from yahoo.search._Search:
app_id
Application ID (issued by Yahoo), same ass appid
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
appid
Application ID (issued by Yahoo)
get = _get_app_id(self)
Get the application ID.
set = _set_app_id(self, app_id)
Set the application ID, which is required.
cc_licenses
List of all supported Creative Commons licenses
get = _get_cc_licenses(self)
Get the list of all supported CC licenses.
countries
List of all supported county codes
get = _get_countries(self)
Get the list of all supported contry codes.
debug_level
Set and modify the debug level
get = _get_debug_level(self)
Get the current debug level.
set = _set_debug_level(self, level)
Set the new debug level to be used.
languages
List of all supported languages
get = _get_languages(self)
Get the list of all supported languages.
regions
List of all supported region codes
get = _get_regions(self)
Get the list of all supported region codes.
subscriptions
List of all supported premium subscriptions
get = _get_subscriptions(self)
Get the list of supported premium subscriptions.
svc_name
Descriptive name of the service
get = _get_svc_name(self)
Get the descriptive service name.
set = _set_svc_name(self, value)
Set the descriptive service name.
svc_protocol
Service protocol (e.g. HTTP)
get = _get_svc_protocol(self)
Get the service protocol (e.g. HTTP).
set = _set_svc_protocol(self, value)
Set the service protocol (must be supported).
svc_server
Service server name or IP
get = _get_svc_server(self)
Get the service server name or IP.
set = _set_svc_server(self, value)
Set the service server name or IP.
svc_service
Service path
get = _get_svc_service(self)
Get the URL path for the service.
set = _set_svc_service(self, value)
Set the URL path for the service.
svc_version
Service version string
get = _get_svc_version(self)
Get the service version string.
set = _set_svc_version(self, value)
Set the service version string.

Data and other attributes inherited from yahoo.search._Search:
METHOD = 'GET'
PROTOCOL = 'http'
SERVER = 'search.yahooapis.com'
VERSION = 'V1'

Data and other attributes inherited from yahoo.search.debug.Debuggable:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Debuggable' objects>
list of weak references to the object (if defined)

 
Data
        __author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Sun Feb 25 21:47:52 MST 2007'
__revision__ = '$Id: web.py,v 1.10 2007/02/28 05:20:11 zwoop Exp $'
__version__ = '$Revision: 1.10 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/docs/yahoo.search.webservices.html0000644001174600001440000005354610671606270020542 0ustar leifusers Python: module yahoo.search.webservices
 
 
yahoo.search.webservices (version 1.32, Tue Sep 11 15:37:37 MDT 2007)
index
/home/leif/hack/pysearch/yahoo/search/webservices.py

Yahoo Search Web Services
 
---   NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE ---
 
     This module is deprecated, please see the documentation for
 
         yahoo.search
 
     and use the new class structures. The old DOM parser is also
     obsolote, and not distributed with this package at all. For
     documentation on the results produced by the various search
     classes, please refer to the appropriate DOM parser docs.
 
---   NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE ---
 
 
This module implements a set of classes and functions to work with the
Yahoo Search Web Services. All results from these services are properly
formatted XML, and this package facilitates for proper parsing of these
result sets. Some of the features include:
 
    * Extendandable API, with replaceable backend XML parsers, and
      I/O interface.
    * Type and value checking on search parameters, including
      automatic type conversion (when appropriate and possible)
    * Flexible return format, including DOM objects, or fully
      parsed result objects
 
 
You can either instantiate a search object directly, or use the factory
function create_search() in this module (see below). The supported classes
of searches are:
    
    VideoSearch - Video Search
    ImageSearch - Image Search
    WebSearch   - Web Search
    NewsSearch  - News Search
    LocalSearch - Local Search
 
    RelatedSuggestion   - Web Search Related Suggestion
    SpellingSuggestion  - Web Search Spelling Suggestion
 
    TermExtraction - Term Extraction service
    ContextSearch  - Web Search with a context
 
 
The different sub-classes of Search supports different sets of query
parameters. They all require an application ID parameter (app_id). The
following tables describes all other allowed parameters for each of the
supported services:
 
                Web   Related  Spelling  Context   Term
               -----  -------  --------  -------  ------
    query       [X]     [X]       [X]      [X]      [X]
    type        [X]      .         .       [X]       .
    results     [X]     [X]        .       [X]       .
    start       [X]      .         .       [X]       .
 
    format      [X]      .         .        .        .
    adult_ok    [X]      .         .       [X]       .
    similar_ok  [X]      .         .       [X]       .
    language    [X]      .         .        .        .
    country     [X]      .         .        .        .
    context      .       .         .       [X]      [X]
 
 
                Image  Video  News   Local
                -----  -----  -----  -----
    query        [X]    [X]    [X]    [X]
    type         [X]    [X]    [X]     . 
    results      [X]    [X]    [X]    [X]
    start        [X]    [X]    [X]    [X]
 
    format       [X]    [X]     .      .
    adult_ok     [X]    [X]     .      .
    language      .      .      .     [X]
    country       .      .      .      .
    sort          .      .     [X]    [X]
    coloration   [X]     .      .      .
 
    radius        .      .      .     [X]
    street        .      .      .     [X]
    city          .      .      .     [X]
    state         .      .      .     [X]
    zip           .      .      .     [X]
    location      .      .      .     [X]
    longitude     .      .      .     [X]
    latitude      .      .      .     [X]
 
 
Each of these parameter is implemented as an attribute of each
respective class. For example, you can set parameters like:
 
    from yahoo.search.webservices import WebSearch
 
    app_id = "YahooDemo"
    srch = WebSearch(app_id)
    srch.query = "Leif Hedstrom"
    srch.results = 40
 
or, if you are using the factory function:
    
    from yahoo.search.webservices import create_search
 
    app_id = "YahooDemo"
    srch = create_search("Web", app_id, query="Leif Hedstrom", results=40)
 
or, the last alternative, a combination of the previous two:
 
    from yahoo.search.webservices import WebSearch
 
    app_id = "YahooDemo"
    srch = WebSearch(app_id, query="Leif Hedstrom", results=40)
 
To retrieve a certain parameter value, simply access it as any normal
attribute:
 
    print "Searched for ", srch.query
 
 
For more information on these parameters, and their allowed values, please
see the official Yahoo Search Services documentation available at
 
    http://developer.yahoo.net/
 
Once the webservice object has been created, you can retrieve a parsed
object (typically a DOM object) using the get_results() method:
 
    dom = srch.get_results()
 
This DOM object contains all results, and can be used as is. For easier
use of the results, you can use the built-in results factory, which will
traverse the entire DOM object, and create a list of results objects.
 
    results = srch.parse_results(dom)
 
or, by using the implicit call to get_results():
 
    results = srch.parse_results()
    
The default XML parser and results factories should be adequate for most
users, so use the parse_results() when possible. However, both the XML
parser and the results parser can easily be overriden. See the examples
below for details.
 
 
EXAMPLES:
 
This simple application will create a search object using the first
command line argument as the "type" (e.g. "web" or "news"), and all
subsequent arguments forms the query string:
 
    #!/usr/bin/python
 
    import sys
    from yahoo.search.webservices import create_search
 
    service = sys.argv[1]
    query = " ".join(sys.argv[2:])
    app_id = "YahooDemo"
    srch = create_search(service, app_id, query=query, results=5)
    if srch is None:
        srch = create_search("Web", app_id, query=query, results=5)
 
    dom = srch.get_results()
    results = srch.parse_results(dom)
 
    for res in results:
        url = res.Url
        summary = res['Summary']
        print "%s -> %s" (summary, url)
 
 
The same example using the PyXML 4DOM parser:
 
    #!/usr/bin/python
 
    import sys
    from yahoo.search.webservices import create_search
    from xml.dom.ext.reader import Sax2
 
    query = " ".join(sys.argv[2:])
    srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5)
 
    if srch is not None:
        reader = Sax2.Reader()
        srch.install_xml_parser(reader.fromStream)
        .
        .
        .
 
 
The last example will produce the same query, but uses an HTTP proxy
for the request:
 
    #!/usr/bin/python
 
    import sys
    from yahoo.search.webservices import create_search
    import urllib2
 
    query = " ".join(sys.argv[2:])
    srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5)
 
    if srch is not None:
        proxy = urllib2.ProxyHandler({"http" : "http://octopus:3128"})
        opener = urllib2.build_opener(proxy)
        srch.install_opener(opener)
        .
        .
        .
 
 
You can obviously "mix and match" as necessary here. I'm using the
installer methods above for clarity, the APIs allows you to pass those
custom handlers as arguments as well (see the documentation below).

 
Modules
       
types
yahoo

 
Data
        CC_LICENSES = {'cc_any': 'Any', 'cc_commercial': 'Commercial', 'cc_modifiable': 'Modifiable'}
COUNTRIES = {'any': 'any', 'ar': 'Argentina', 'at': 'Austria', 'au': 'Australia', 'be': 'Belgium', 'br': 'Brazil', 'ca': 'Canada', 'ch': 'Switzerland', 'cn': 'China', 'cz': 'Czechoslovakia', ...}
LANGUAGES = {'ar': 'arabic', 'bg': 'bulgarian', 'ca': 'catalan', 'cs': 'czech', 'da': 'danish', 'de': 'german', 'default': 'english', 'el': 'greek', 'en': 'english', 'es': 'spanish', ...}
SERVICES = {'album': (<class 'yahoo.search.audio.AlbumSearch'>, 'Search for a specific music album'), 'artist': (<class 'yahoo.search.audio.ArtistSearch'>, 'Information on a musical performer'), 'context': (<class 'yahoo.search.web.ContextSearch'>, 'Contextual Web Search'), 'image': (<class 'yahoo.search.image.ImageSearch'>, 'Image Search'), 'inlinkdata': (<class 'yahoo.search.site.InlinkData'>, 'Show pages linking to a specific page'), 'local': (<class 'yahoo.search.local.LocalSearch'>, 'Local Search'), 'news': (<class 'yahoo.search.news.NewsSearch'>, 'News Search'), 'pagedata': (<class 'yahoo.search.site.PageData'>, 'Find all pages belonging to a domain'), 'podcast': (<class 'yahoo.search.audio.PodcastSearch'>, 'Search for a Podcast site/feed'), 'related': (<class 'yahoo.search.web.RelatedSuggestion'>, 'Web Search Related Suggestion'), ...}
SUBSCRIPTIONS = {'cr': 'Consumer Reports', 'forrester': 'Forrester Research', 'ft': 'FT.com', 'ieee': 'IEEE publications', 'nejm': 'New England Journal of Medicine', 'thestreet': 'TheStreet.com', 'wsj': 'Wall Street Journal'}
__author__ = 'Leif Hedstrom <leif@ogre.com>'
__date__ = 'Tue Sep 11 15:37:37 MDT 2007'
__revision__ = '$Id: webservices.py,v 1.32 2007/09/11 21:38:43 zwoop Exp $'
__version__ = '$Revision: 1.32 $'

 
Author
        Leif Hedstrom <leif@ogre.com>
pYsearch-3.1/examples/0000755001174600001440000000000010671606606013625 5ustar leifuserspYsearch-3.1/examples/profile.py0000755001174600001440000000075510205555655015651 0ustar leifusers#!/usr/bin/python from yahoo.search import webservices from yahoo.search.debug import DEBUG_LEVELS import hotshot def tester(): x = webservices.create_search("web", "YahooDemo", query="leif hedstrom", results=20) srch = x.parse_results() if __name__ == "__main__": prof = hotshot.Profile("ysearch.prof", lineevents=1) prof.runcall(tester) prof.close() print "Convert this to a kcachegrind callstack with:" print "hotshot2calltree -o ysearch.out ysearch.prof" pYsearch-3.1/examples/websearch.py0000755001174600001440000002366710570462204016153 0ustar leifusers#!/usr/bin/python import sys import getopt from yahoo.search import factory, debug # # Print usage/help information, and exit # def usage_exit(msg=None): if msg: print "Error: ", print msg print print """\ Usage: websearch [options] query Options: -h, --help Show this message -t, --type Yahoo search service type (web, news, context, image, video, spelling, related, podcast, pagedata or inlinkdata) -i, --appid Application ID to send to Yahoo servers -r, --results Show this many results -s, --start Show results starting at this position -a, --adult-ok Allow adult content in the results -f, --format Limit the search to specific data formats -l, --license Creative Commons License -L, --language Language (only for web search) -c, --country Country (only for web search) -S, --subscription Subscription code (web search only) -R, --region The region to send the search to (e.g. "uk") -C, --coloration Coloration of images (image search only) -x, --context Context string (for context search and term extraction) -u, --site Site information/URL (used for site discovery services) -F, --flag Flag (0 or 1) used by various services -D, --raw Print a "raw" version of each result -j, --json Get the results as JSON objects -p, --php Get the results as PHP code -v, --verbose Show more verbose results, including summary -d, --debug Turn on some debugging information Examples: websearch.py -t news -s 50 -r 20 -a Yahoo websearch.py -v -t web -f pdf "Linux threads" """ sys.exit(2) # # Parse arguments and create the search object # if __name__ == "__main__": # Options/settings params = { 'verbose' : 0, 'raw' : 0, 'debug' : 0, 'type' : 'Web', 'results' : 10, 'start' : 1, 'adult' : None, 'format' : None, 'language' : None, 'country' : None, 'coloration' : None, 'context' : None, 'region' : None, 'appid' : 'YahooDemo', 'flag' : 0, 'json' : 0, 'php' : 0, 'license' : [], 'site' : [], 'subscription' : [], } try: options, args = getopt.getopt(sys.argv[1:], 'hHt:i:r:s:af:l:L:c:S:R:C:x:u:F:Djpvd:', ['help', 'type=', 'appid=', 'results=', 'start=', 'adult-ok', 'format=', 'license=', 'language=', 'country=', 'subscription=', 'region=', 'coloration=', 'context=', 'site=', 'flag=', 'raw', 'json', 'php', 'verbose', 'debug=', ]) for opt, value in options: if opt in ('-h', '-H','--help'): usage_exit() elif opt in ('-v', '--verbose'): params['verbose'] += 1 elif opt in ('-D', '--raw'): params['raw'] += 1 elif opt in ('-j', '--json'): params['json'] += 1 elif opt in ('-p', '--php'): params['php'] += 1 elif opt in ('-t', '--type'): params['type'] = value.lower() elif opt in ('-r', '--results'): try: params['results'] = int(value) except ValueError: usage_exit("Results must be an integer between 1 and 50") elif opt in ('-s', '--start'): try: params['start'] = int(value) except ValueError: usage_exit("Start must be an integer") elif opt in ('-a', '--adult-ok'): params['adult'] = 1 elif opt in ('-f', '--format'): params['format'] = value elif opt in ('-l', '--license'): if not value.lower() in params['license']: params['license'].append(value.lower()) elif opt in ('-u', '--site'): if not value in params['site']: params['site'].append(value) elif opt in ('-S', '--subscription'): if not value.lower() in params['subscription']: params['subscription'].append(value.lower()) elif opt in ('-L', '--language'): params['language'] = value elif opt in ('-c', '--country'): params['country'] = value elif opt in ('-R', '--region'): params['region'] = value elif opt in ('-C', '--coloration'): params['coloration'] = value elif opt in ('-x', '--context'): params['context'] = value elif opt in ('-F', '--flag'): try: params['flag'] = int(value) except ValueError: usage_exit("Flag must be an integer, 0 or 1") elif opt in ('-i', '--appid'): params['appid'] = value elif opt in ('-d', '--debug'): if debug.DEBUG_LEVELS.has_key(value.upper()): params['debug'] = params['debug'] | debug.DEBUG_LEVELS[value.upper()] else: try: params['debug'] = int(value) except: usage_exit("Debug value must be a valid string or integer") except getopt.error, msg: usage_exit(msg) try: srch = factory.create_search(params['type'], params['appid'], debug_level=params['debug']) except ValueError: usage_exit("AppID can only contain a-zA-Z0-9 _()[]*+-=,.:\@, 8-40 characters") if srch is None: usage_exit("%s is not a valid search service type" % params['type']) if params['format'] is not None: try: srch.format = params['format'] except ValueError, err: usage_exit(err) if params['adult'] is not None: srch.adult_ok = 1 if params['language'] is not None: srch.language = params['language'] if params['country'] is not None: srch.country = params['country'] if params['region'] is not None: srch.region = params['region'] if params['coloration'] is not None: srch.coloration = params['coloration'] if params['context'] is not None: srch.context = params['context'] if len(params['license']) > 0: srch.license = params['license'] if len(params['site']) > 0: srch.site = params['site'] if len(params['subscription']) > 0: srch.subscription = params['subscription'] if params['json'] > 0: srch.output = "json" elif params['php'] > 0: srch.output = "php" # This is odd, but useful ... if params['flag'] > 0: if params['type'] == 'inlinkdata': srch.entire_site = params['flag'] elif params['type'] == 'pagedata': srch.domain_only = params['flag'] srch.results = params['results'] srch.start = params['start'] srch.query = " ".join(args) if srch.query == "" and params['type'].lower() != 'term': usage_exit("You must provide a search query") if ((params['json'] > 0) or (params['php'] > 0)): print srch.get_results() else: try: results = srch.parse_results() except Exception, err: print "Got an error ->", err sys.exit(1) if results.total_results_returned > 0: print "Search for %s -> %s results (showing %d - %d)\n" % ( srch.query, results.total_results_available, srch.start, srch.start + results.total_results_returned - 1) # The try clauses are weird, but it seems less and other apps can cause # the decoding of Unicode characters to raise exceptions. cnt = srch.start if (params['type'].lower() in ("spelling", "related", "term") or params['raw'] > 0): result_only = True else: result_only = False for res in results: try: if result_only: print "[%3d]\t%s" % (cnt, res) else: print "[%3d]\t%s\n\t%s" % (cnt, res.Title, res.Url) except UnicodeEncodeError: print "[%3d]\tfailed to decode data" % (cnt) cnt += 1 if params['verbose'] > 0: try: print "\t%s" % (res.Summary) except UnicodeEncodeError: print "\tfailed to decode Summary" if params['verbose'] > 1: try: print res except UnicodeEncodeError: pass else: print "No results" # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/test/0000755001174600001440000000000010671606606012766 5ustar leifuserspYsearch-3.1/test/audio.py0000644001174600001440000000603510571210407014432 0ustar leifusers"""Unit tests for all yahoo.search.image classes """ import unittest from searchbase import SearchServiceTest from yahoo.search.audio import * __revision__ = "$Id: audio.py,v 1.4 2007/02/28 05:20:07 zwoop Exp $" __version__ = "$Revision: 1.4 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 12 14:35:18 MDT 2006" # # Test for artist search # class ArtistSearchTestCase(SearchServiceTest, unittest.TestCase): """ArtistSearchTestCase - ArtistSearch Unit tests. """ SERVICE = ArtistSearch NUM_PARAMS = 7 def testQueryParam(self): """Verify that the query parameter is accepted (%s)""" % self.SERVICE self.srch.artist = "Madonna" self.assertEqual(self.srch.artist, "Madonna") # Now test a simple query, this will be overriden where appropriate def testSimpleQuery(self): """Test one simple query and the XML result (%s)""" % self.SERVICE import xml.dom.minidom self.srch.artist = "Madonna" dom = self.srch.get_results() self.assertTrue(isinstance(dom, xml.dom.minidom.Document)) res = self.srch.parse_results(dom) self.assertFalse(res.total_results_available == 0) self.assertTrue(res.first_result_position > 0) # # Test for album search # class AlbumSearchTestCase(ArtistSearchTestCase): """AlbumSearchTestCase - AlbumSearch Unit tests. """ SERVICE = AlbumSearch NUM_PARAMS = 9 # # Test for song search # class SongSearchTestCase(ArtistSearchTestCase): """SongSearchTestCase - SongSearch Unit tests. """ SERVICE = SongSearch NUM_PARAMS = 11 # # Test for song download location # class SongDownloadLocationTestCase(SearchServiceTest, unittest.TestCase): """SongDownloadLocationTestCase - SongSearch Unit tests. """ SERVICE = SongDownloadLocation NUM_PARAMS = 6 def testQueryParam(self): """Verify that the query parameter is accepted (%s)""" % self.SERVICE self.srch.songid = "XXXXXXT002734753" self.assertEqual(self.srch.songid, "XXXXXXT002734753") # Now test a simple query, this will be overriden where appropriate def testSimpleQuery(self): """Test one simple query and the XML result (%s)""" % self.SERVICE import xml.dom.minidom self.srch.songid = "XXXXXXT002734753" dom = self.srch.get_results() self.assertTrue(isinstance(dom, xml.dom.minidom.Document)) res = self.srch.parse_results(dom) self.assertFalse(res.total_results_available == 0) self.assertTrue(res.first_result_position > 0) # # Test for podcast search # class PodcastSearchTestCase(SearchServiceTest, unittest.TestCase): """PodcastSearchTestCase - PodcastSearch Unit tests. """ SERVICE = PodcastSearch NUM_PARAMS = 8 TEST_QUERY = "science" def testSimpleQuery(self): """This service doesn't seem to work ...""" pass # # Finally, run all the tests # if __name__ == '__main__': unittest.main() # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/test/image.py0000644001174600001440000000131210571210410014376 0ustar leifusers"""Unit tests for all yahoo.search.image classes """ import unittest from searchbase import SearchServiceTest from yahoo.search.image import * __revision__ = "$Id: image.py,v 1.2 2007/02/28 05:20:08 zwoop Exp $" __version__ = "$Revision: 1.2 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 12 13:34:35 MDT 2006" # # Test for image search # class ImageSearchTestCase(SearchServiceTest, unittest.TestCase): """ImageSearchTestCase - ImageSearch Unit tests. """ SERVICE = ImageSearch NUM_PARAMS = 10 # # Finally, run all the tests # if __name__ == '__main__': unittest.main() # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/test/local.py0000644001174600001440000000223310571210410014411 0ustar leifusers"""Unit tests for all yahoo.search.local classes """ import unittest from searchbase import SearchServiceTest from yahoo.search.local import * __revision__ = "$Id: local.py,v 1.2 2007/02/28 05:20:08 zwoop Exp $" __version__ = "$Revision: 1.2 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 15:23:03 MST 2007" # # Test for local search # class LocalSearchTestCase(SearchServiceTest, unittest.TestCase): """LocalSearchTestCase - LocalSearch Unit tests. """ SERVICE = LocalSearch NUM_PARAMS = 18 def testSimpleQuery(self): """Test one simple query and the XML result (%s)""" % self.SERVICE import xml.dom.minidom self.srch.query = "yahoo" self.srch.zip = "94019" dom = self.srch.get_results() self.assertTrue(isinstance(dom, xml.dom.minidom.Document)) res = self.srch.parse_results(dom) self.assertFalse(res.total_results_available == 0) self.assertTrue(res.first_result_position > 0) # # Finally, run all the tests # if __name__ == '__main__': unittest.main() # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/test/news.py0000644001174600001440000000130110571210410014266 0ustar leifusers"""Unit tests for all yahoo.search.news classes """ import unittest from searchbase import SearchServiceTest from yahoo.search.news import * __revision__ = "$Id: news.py,v 1.3 2007/02/28 05:20:08 zwoop Exp $" __version__ = "$Revision: 1.3 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 12 13:34:07 MDT 2006" # # Test for news search # class NewsSearchTestCase(SearchServiceTest, unittest.TestCase): """NewsSearchTestCase - NewsSearch Unit tests. """ SERVICE = NewsSearch NUM_PARAMS = 9 # # Finally, run all the tests # if __name__ == '__main__': unittest.main() # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/test/searchbase.py0000644001174600001440000000524610571210410015426 0ustar leifusers"""Base classes for Y! Search Services """ import unittest import yahoo.search __revision__ = "$Id: searchbase.py,v 1.4 2007/02/28 05:20:08 zwoop Exp $" __version__ = "$Revision: 1.4 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 12 15:59:04 MDT 2006" # # These are "shared" tests, across all the services # class SearchServiceTest(object): """Base class for our Unit tests.""" SERVICE = None NUM_PARAMS = 999 TEST_QUERY = "Yahoo" EXPECTED_RESULTS = -1 def setUp(self): """Setup the search test system for Unit tests.""" self.srch = self.SERVICE('YahooDemo') # First some very basic tests def testInstantiation(self): """Instantiate a search object (%s)""" % self.SERVICE self.assertNotEqual(self.srch, None) def testValidParams(self): """Verify that allowed parameters are correct (%s)""" % self.SERVICE params = self.srch.get_valid_params() self.assertEqual(len(params), self.NUM_PARAMS) for param in self.srch._valid_params.values(): self.assertEqual(len(param), 6) self.assertNotEqual(len(self.srch.missing_params()), 0) def testQueryParam(self): """Verify that the query parameter is accepted (%s)""" % self.SERVICE self.srch.query = self.TEST_QUERY self.assertEqual(self.srch.query, self.TEST_QUERY) def testUnknownParam(self): """An exception must be raised on bad parameters (%s)""" % self.SERVICE self.assertRaises(yahoo.search.ParameterError, self.srch.set_param, "FooBar", "Fum") # Now test a simple query, this will be overriden where appropriate def testSimpleQuery(self): """Test one simple query and the XML result (%s)""" % self.SERVICE import xml.dom.minidom self.srch.query = self.TEST_QUERY dom = self.srch.get_results() self.assertTrue(isinstance(dom, xml.dom.minidom.Document)) res = self.srch.parse_results(dom) self.assertFalse(res.total_results_available == 0) self.assertTrue(res.first_result_position > 0) if self.EXPECTED_RESULTS > -1: self.assertTrue(res.total_results_available == self.EXPECTED_RESULTS) self.srch.output = "json" json = self.srch.get_results() self.assertTrue(len(json) > 0) self.srch.output = "php" json = self.srch.get_results() self.assertTrue(len(json) > 0) self.srch.output = "xml" def testProperties(self): """Test that various class properties work (%s)""" % self.SERVICE self.assertEqual(self.srch.appid, 'YahooDemo') self.assertEqual(self.srch.app_id, 'YahooDemo') pYsearch-3.1/test/site.py0000644001174600001440000000417710571210411014275 0ustar leifusers"""Unit tests for all yahoo.search.web classes """ import unittest from searchbase import SearchServiceTest from yahoo.search.site import * __revision__ = "$Id: site.py,v 1.2 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.2 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 22:14:35 MST 2007" # # Test for PageData # class PageDataTestCase(SearchServiceTest, unittest.TestCase): """PageDataTestCase - PageData Unit tests. """ SERVICE = PageData NUM_PARAMS = 6 TEST_QUERY = "http://www.yahoo.com" def testBadParamValues(self): """Make sure bad parameter values are caught (%s)""" % self.SERVICE self.assertRaises(ValueError, self.srch.set_param, "results", "200") self.assertRaises(ValueError, self.srch.set_param, "start", -1) # # Test for InlinkData # class InlinkDataTestCase(SearchServiceTest, unittest.TestCase): """InlinkDataTestCase - InlinkData Unit tests. """ SERVICE = InlinkData NUM_PARAMS = 7 TEST_QUERY = "http://www.yahoo.com" # # Test for UpdateNotification # class UpdateNotificationTestCase(SearchServiceTest, unittest.TestCase): """UpdateNotificationTestCase - UpdateNotification Unit tests. """ SERVICE = UpdateNotification NUM_PARAMS = 1 GOOD_URL = "http://www.yahoo.com" BAD_URL = "www.yahoo.com" def testQueryParam(self): """Verify that the URL parameter is accepted (%s)""" % self.SERVICE self.srch.url = self.GOOD_URL self.assertEqual(self.srch.url, self.GOOD_URL) # Now test a simple query, this will be overriden where appropriate def testSimpleQuery(self): """Test one simple query and the XML result (%s)""" % self.SERVICE import xml.dom.minidom self.srch.url = self.GOOD_URL dom = self.srch.get_results() self.assertTrue(isinstance(dom, xml.dom.minidom.Document)) res = self.srch.parse_results(dom) self.assertTrue(res.results[0].Success) # # Finally, run all the tests # if __name__ == '__main__': unittest.main() # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/test/term.py0000644001174600001440000000230010571210411014262 0ustar leifusers"""Unit tests for all yahoo.search.term classes """ import unittest from searchbase import SearchServiceTest from yahoo.search.term import * __revision__ = "$Id: term.py,v 1.2 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.2 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 12 13:35:34 MDT 2006" # # Test for Term Extraction # class TermExtractionTestCase(SearchServiceTest, unittest.TestCase): """TermExtractionTestCase - TermExtraction Unit tests. """ SERVICE = TermExtraction NUM_PARAMS = 4 def testSimpleQuery(self): """Test one simple query and the XML result (%s)""" % self.SERVICE import xml.dom.minidom self.srch.query = "Yahoo" self.srch.context = "Web Search APIs developers" dom = self.srch.get_results() self.assertTrue(isinstance(dom, xml.dom.minidom.Document)) res = self.srch.parse_results(dom) self.assertFalse(res.total_results_available == 0) self.assertTrue(res.first_result_position > 0) # # Finally, run all the tests # if __name__ == '__main__': unittest.main() # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/test/video.py0000644001174600001440000000131110571210411014422 0ustar leifusers"""Unit tests for all yahoo.search.video classes """ import unittest from searchbase import SearchServiceTest from yahoo.search.video import * __revision__ = "$Id: video.py,v 1.3 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.3 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 12 13:34:19 MDT 2006" # # Test for video search # class VideoSearchTestCase(SearchServiceTest, unittest.TestCase): """VideoSearchTestCase - VideoSearch Unit tests. """ SERVICE = VideoSearch NUM_PARAMS = 9 # # Finally, run all the tests # if __name__ == '__main__': unittest.main() # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/test/web.py0000644001174600001440000000737110571210411014105 0ustar leifusers"""Unit tests for all yahoo.search.web classes """ import unittest from searchbase import SearchServiceTest from yahoo.search.web import * __revision__ = "$Id: web.py,v 1.4 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.4 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 12 15:59:34 MDT 2006" # # Test for WebSearch # class WebSearchTestCase(SearchServiceTest, unittest.TestCase): """WebSearchTestCase - WebSearch Unit tests. """ SERVICE = WebSearch NUM_PARAMS = 15 def testBadParamValues(self): """Make sure bad parameter values are caught (%s)""" % self.SERVICE self.assertRaises(ValueError, self.srch.set_param, "results", "200") self.assertRaises(ValueError, self.srch.set_param, "start", -1) self.assertRaises(ValueError, self.srch.set_param, "similar_ok", 3) self.assertRaises(ValueError, self.srch.set_param, "format", "foo") self.assertRaises(ValueError, self.srch.set_param, "language", "Here") self.assertRaises(ValueError, self.srch.set_param, "country", "there") self.assertRaises(ValueError, self.srch.set_param, "license", "cc_none") self.assertRaises(ValueError, self.srch.set_param, "region", "qq") def test4DOM(self): """Test an alternative DOM parser, 4DOM (%s)""" % self.SERVICE try: from xml.dom.ext.reader import Sax2 import xml.dom.Document except: pass else: srch = self.SERVICE('YahooDemo') srch.install_xml_parser(Sax2.Reader().fromStream) srch.query = "Yahoo" dom = srch.get_results() self.assertTrue(isinstance(dom, xml.dom.Document.Document)) # # Test for context search # class ContextSearchTestCase(SearchServiceTest, unittest.TestCase): """ContextSearchTestCase - ContextSearch Unit tests. """ SERVICE = ContextSearch NUM_PARAMS = 13 def testBadParamValues(self): """Make sure bad parameter values are caught (%s)""" % self.SERVICE self.assertRaises(ValueError, self.srch.set_param, "results", "200") self.assertRaises(ValueError, self.srch.set_param, "start", -1) self.assertRaises(ValueError, self.srch.set_param, "similar_ok", 3) self.assertRaises(ValueError, self.srch.set_param, "format", "foo") self.assertRaises(ValueError, self.srch.set_param, "language", "Here") self.assertRaises(ValueError, self.srch.set_param, "country", "there") self.assertRaises(ValueError, self.srch.set_param, "license", "cc_none") def testSimpleQuery(self): """Test one simple query and the XML result (%s)""" % self.SERVICE import xml.dom.minidom self.srch.query = "Yahoo" self.srch.context = "Web Search APIs developers" dom = self.srch.get_results() self.assertTrue(isinstance(dom, xml.dom.minidom.Document)) res = self.srch.parse_results(dom) self.assertFalse(res.total_results_available == 0) self.assertTrue(res.first_result_position > 0) # # Test for related suggestion # class RelatedSuggestionTestCase(SearchServiceTest, unittest.TestCase): """RelatedSuggestionTestCase - RelatedSuggestion Unit tests. """ SERVICE = RelatedSuggestion NUM_PARAMS = 4 TEST_QUERY = "yahoo" EXPECTED_RESULTS = 10 # # Test for spelling suggestion # class SpellingSuggestionTestCase(SearchServiceTest, unittest.TestCase): """SpellingSuggestionTestCase - SpellingSuggestion Unit tests. """ SERVICE = SpellingSuggestion NUM_PARAMS = 3 TEST_QUERY = "yahok" EXPECTED_RESULTS = 1 # # Finally, run all the tests # if __name__ == '__main__': unittest.main() # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/0000755001174600001440000000000010671606606013126 5ustar leifuserspYsearch-3.1/yahoo/search/0000755001174600001440000000000010671606606014373 5ustar leifuserspYsearch-3.1/yahoo/search/dom/0000755001174600001440000000000010671606606015152 5ustar leifuserspYsearch-3.1/yahoo/search/dom/__init__.py0000644001174600001440000001332410571210413017250 0ustar leifusers"""Base class for search results parsing This package implements the interface and base class that should be used for all parsers of the web results. It is used by the DOM parsers that we provide as defaults. """ __revision__ = "$Id: __init__.py,v 1.6 2007/02/28 05:20:11 zwoop Exp $" __version__ = "$Revision: 1.6 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 16:27:58 MST 2007" from yahoo.search import parser import yahoo.search.debug # # DOM parser implementation of the search parser. # class DOMResultParser(parser.ResultParser): """DomResultParser - Base class for Yahoo Search DOM result parsers This is a DOM specific parser that is used as a base class for all Yahoo Search result parsers. It obviously must implement the main entry entry point, parse_results(). """ def parse_results(self, dom_object): """This is a simple DOM parser for all Yahoo Search services. It expects to find a top-level node named ResultSet. This is the main entry point for the DOM parser, and it requires a properly con- structed DOM object (e.g. using minidom). """ try: result_set = dom_object.getElementsByTagName('ResultSet')[0] except: raise parser.XMLError("DOM object has no ResultSet") self._parse_result_set(result_set) def _get_text(self, nodelist, casting=None): """Find all text nodes for the nodelist, and concatenate them into one resulting strings. This is a helper method for the DOM parser. """ rcode = "" for node in nodelist: if node.nodeType == node.TEXT_NODE: rcode = rcode + node.data if casting is not None: if rcode == "": return rcode else: return casting(rcode) else: return rcode def _tag_to_list(self, node, tag, casting=None): """Turn a number of tag elements into a list of values.""" ret = [] if casting is not None: for item in node.getElementsByTagName(tag): ret.append(casting(self._get_text(item.childNodes))) else: for item in node.getElementsByTagName(tag): ret.append(self._get_text(item.childNodes)) def _tags_to_dict(self, node, tags): """Internal method to parse and extract a list of tags from a particular node. We return a dict, which can potentially be empty. The tags argument is a list of lists, where each sub-list is (tag-name, default value/None, casting function/None) The default "type" of a value is string, so there is no reason to explicitly cast to a str. """ res = self._res_dict() for tag in tags: elem = node.getElementsByTagName(tag[0]) if elem: val = self._get_text(elem[0].childNodes, tag[2]) elif tag[1] is not None: val = tag[1] else: raise parser.XMLError("Result is missing a %s node" % tag[0]) res[tag[0]] = val return res def _id_attribute_to_dict(self, node): """Internal method to parse and extract a node value, which has an "id" attribute as well. This will return a result dict with two values: { 'Name' : , 'Id' : } """ res = self._res_dict() res['Name'] = self._get_text(node.childNodes) node_id = node.attributes.getNamedItem('id') if node_id: res['Id'] = str(node_id.nodeValue) else: raise parser.XMLError("%s node has no id attribute" % node.nodeName) return res def _parse_list_node(self, node, tag): """Internal method to parse a result node, which contains one or more data nodes. Each such node is converted to a dict (see _id_attribute_to_dict), and we return a list of such dicts. """ res = [] for elem in node.getElementsByTagName(tag): res.append(self._id_attribute_to_dict(elem)) return res def _parse_result_set(self, result_set): """Internal method to parse a ResultSet node""" attributes = result_set.attributes if not attributes: raise parser.XMLError("ResultSet has no attributes") attr = attributes.getNamedItem('totalResultsAvailable') if attr: self._total_results_available = int(attr.nodeValue) else: raise parser.XMLError("ResultSet has no totalResultsAvailable attr") attr = attributes.getNamedItem('totalResultsReturned') if attr: self._total_results_returned = int(attr.nodeValue) else: raise parser.XMLError("ResultSet has no totalResultsReturned attr") attr = attributes.getNamedItem('firstResultPosition') if attr: self._first_result_position = int(attr.nodeValue) else: raise parser.XMLError("ResultSet has no firstRestultPosition attr") self._service._debug_msg("Results = %d / %d / %d", yahoo.search.debug.DEBUG_LEVELS['PARSING'], self._total_results_available, self._total_results_returned, self._first_result_position); for res in result_set.getElementsByTagName('Result'): self._results.append(self._parse_result(res)) def _parse_result(self, result): """Internal method to parse one Result node""" return self._tags_to_dict(result, self._res_fields) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/dom/audio.py0000644001174600001440000003602710571210413016617 0ustar leifusers"""DOM parser for Audio search results Implement a simple DOM parser for the Yahoo Search Web Services audio search APIs. """ __revision__ = "$Id: audio.py,v 1.4 2007/02/28 05:20:11 zwoop Exp $" __version__ = "$Revision: 1.4 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 14:19:41 MST 2007" from yahoo.search import dom from yahoo.search import parser # # Custom DOM parser for some Audio classes. This will handle the # "id" attribute of artists and songs etc. properly # class _AudioParser(dom.DOMResultParser): """_AudioParser - Custom DOM parser for some Audio classes """ def _tags_to_dict(self, node, tags, parse_id=True): """This specialized version will convert the "id" attribute of the tag to an attribute. """ res = super(_AudioParser, self)._tags_to_dict(node, tags) if parse_id: attr = node.attributes.getNamedItem('id') if attr: res['Id'] = str(attr.nodeValue) else: raise parser.XMLError("Result has no id attr") return res # # Album Search DOM parser # class AlbumSearch(_AudioParser): """AlbumSearch - DOM parser for Album Search Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Title - The title of the album. Artist - The performer of the album, and the unique ID Publisher - The publisher of the album. ReleaseDate - The date of the album's release. Id - Internal ID of the album, unique identifier. The following attributes are optional, and might not be set: Tracks - Number of tracks on the album. Thumbnail - The URL of a thumbnail picture of the album cover. RelatedAlbums - Contains a list of related (similar) albums (IDs). Thumbnail is in turn another dictionary, which will have the following keys: Url - URL of the thumbnail. Height - Height of the thumbnail, in pixels (optional). Width - Width of the thumbnail, in pixels (optional). The two attributes Artist and RelatedAlbums are both lists of dictionaries, with the following two keys: Name - Textual "name" value. Id - Unique identifier (internal yahoo ID). Example: results = ws.parse_results() for res in results: print "%s - %s bytes" % (res.Artist.Name, res.Artist.Id) """ def _init_res_fields(self): """Initialize the valid result fields.""" super(AlbumSearch, self)._init_res_fields() self._res_fields = [('Title', None, None), ('Publisher', None, None), ('ReleaseDate', None, None), ('Tracks', 0, int), ] def _parse_result(self, result): """Internal method to parse one Result node""" res = super(AlbumSearch, self)._parse_result(result) node = result.getElementsByTagName('Thumbnail') if node: res['Thumbnail'] = self._tags_to_dict(node[0], (('Url', None, None), ('Height', 0, int), ('Width', 0, int)), parse_id=False) else: res['Thumbnail'] = None node = result.getElementsByTagName('Artist') if node: res['Artist'] = self._id_attribute_to_dict(node[0]) else: res['Artist'] = None node = result.getElementsByTagName('RelatedAlbums') if node: res['RelatedAlbums'] = self._parse_list_node(node[0], 'Album') else: res['RelatedAlbums'] = None return res # # Artist Search DOM parser # class ArtistSearch(_AudioParser): """ArtistSearch - DOM parser for Artist Search Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Name - The name of the artist. Id - Internal ID of the artist, unique identifier. The following attributes are optional, and might not be set: Thumbnail - The URL of the thumbnail file. RelatedArtists - Contains a list of related artists that fans of the artist in this Result might like. PopularSongs - Contains a list of popular songs by this artist. YahooMusicPage - The URL to link to the artist's page on the Yahoo Music site. This can be empty! Thumbnail is in turn another dictionary, which will have the following keys: Url - URL of the thumbnail. Height - Height of the thumbnail, in pixels (optional). Width - Width of the thumbnail, in pixels (optional). Both RelatedArtist and PopularSongs are lists of IDs, which can be used as an identifier into subsequent Yahoo Audio search calls. Example: results = ws.parse_results() for res in results: print "%s - %s bytes" % (res.Name, res.YahooMusicPage) """ def _init_res_fields(self): """Initialize the valid result fields.""" super(ArtistSearch, self)._init_res_fields() self._res_fields = [('Name', None, None), ('YahooMusicPage', "", None), ] def _parse_result(self, result): """Internal method to parse one Result node""" res = super(ArtistSearch, self)._parse_result(result) node = result.getElementsByTagName('Thumbnail') if node: res['Thumbnail'] = self._tags_to_dict(node[0], (('Url', None, None), ('Height', 0, int), ('Width', 0, int)), parse_id=False) else: res['Thumbnail'] = None node = result.getElementsByTagName('RelatedArtists') if node: res['RelatedArtists'] = self._parse_list_node(node[0], 'Artist') else: res['RelatedArtists'] = None node = result.getElementsByTagName('PopularSongs') if node: res['PopularSongs'] = self._parse_list_node(node[0], 'Song') else: res['PopularSongs'] = None return res # # Song Search DOM parser # class SongSearch(_AudioParser): """SongSearch - DOM parser for Song Search Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Title - The title of the song. Id - Internal ID of the song, unique identifier. Album - The album from which the song was taken, and ID. Artist - The performer of the album, and the unique ID. Publisher - The publisher of the album. Length - The length of the song in seconds. ReleaseDate - The date of the album's release. Track - The track number on the album. ClickUrl - The URL for linking to the audio file. The following attributes are optional, and might not be set: Thumbnail - The URL of a thumbnail picture of the album cover. Thumbnail is in turn another dictionary, which will have the following keys: Url - URL of the thumbnail. Height - Height of the thumbnail, in pixels (optional). Width - Width of the thumbnail, in pixels (optional). The two attributes Artist and RelatedAlbums are both lists of dicts, with the keys: Name - Textual "name" value. Id - Unique identifier (internal yahoo ID). Example: results = ws.parse_results() for res in results: print "%s - %s bytes" % (res.Artist.Name, res.Title) """ def _init_res_fields(self): """Initialize the valid result fields.""" self._res_fields = [('Title', None, None), ('Publisher', None, None), ('Length', None, int), ('ReleaseDate', None, None), ('Track', None, int), ('ClickUrl', "", None), ] def _parse_result(self, result): """Internal method to parse one Result node""" res = super(SongSearch, self)._parse_result(result) node = result.getElementsByTagName('Thumbnail') if node: res['Thumbnail'] = self._tags_to_dict(node[0], (('Url', None, None), ('Height', 0, int), ('Width', 0, int)), parse_id=False) else: res['Thumbnail'] = None node = result.getElementsByTagName('Artist') if node: res['Artist'] = self._id_attribute_to_dict(node[0]) else: res['Artist'] = None node = result.getElementsByTagName('Album') if node: res['Album'] = self._id_attribute_to_dict(node[0]) else: res['Album'] = None return res # # Song Download Location DOM parser # class SongDownloadLocation(dom.DOMResultParser): """SongDownloadLocation - DOM parser for Song Download Location Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Source - The source provider for the file. Url - The url for accessing the file. Format - The format the file has been encoded in. The following attributes are optional, and might not be set: Price - The price, in dollars, of the song. Length - The length of the song in seconds. Channels - The number of channels. Usually 1 (mono) or 2 (stereo). Restrictions - A space-separated list of restrictions: * drm denotes files with some form of digital rights management. * subrequired means a subscription to the appropriate service is required. * subnotrequired means a subscription to the appropriate service is not required. * win denotes files that will play on Windows. * mac denotes files that will play on Macintosh. * copyokay means this file may be copied. * copynotokay means this file may not be copied. * cdokay means this file may be burned to CD. Quality - A quality metric for files found on the web. Values range from 1 (worst) to 5 (best). Example: results = ws.parse_results() for res in results: print "%s - %s bytes" % (res.Name, res.YahooMusicPage) """ def _init_res_fields(self): """Initialize the valid result fields.""" super(SongDownloadLocation, self)._init_res_fields() self._res_fields = [('Source', None, None), ('Url', None, None), ('Format', None, None), ('Price', 0.0, float), ('Length', 0, int), ('Channels', "", None), ('Restrictions', "", None), ('Quality', 0, int), ] # # Podcast Search DOM parser # class PodcastSearch(dom.DOMResultParser): """PodcastSearch - DOM parser for Podcast Search Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Title - The title of the audio file. Summary - Summary text associated with the audio file. Url - The URL for the audio file or stream. ClickUrl - The URL for linking to the audio file. RefererUrl - The URL of the web page hosting the content. FileSize - The size of the file, in bytes. FileFormat - One of aiff, midi, mp3, msmedia, quicktime, realmedia, wav or other. Duration - The duration of the audio file in seconds. Streaming - Whether the audio file is streaming or not. The following attributes are optional, and might not be set: SampleSize - The number of bits used in sampling the sound. Channels - The number of channels in the audio. Usually 1 (mono) or 2 (stereo). Publisher - The creator of the video file. Restrictions - Provides any restrictions for this media object. Restrictions include noframe and noinline. See developer site for more info. Copyright - The copyright owner. If present, the Thumbnail value is in turn another dictionary, which will have these keys: Url - URL of the thumbnail. Height - Height of the thumbnail in pixels (optional). Width - Width of the thumbnail in pixels (optional). Example: results = ws.parse_results(dom) for res in results: print "%s - %s bytes" % (res.Title, res.FileSize) """ def _init_res_fields(self): """Initialize the valid result fields.""" super(PodcastSearch, self)._init_res_fields() self._res_fields.extend((('RefererUrl', None, None), ('FileSize', None, int), ('FileFormat', None, None), ('Streaming', None, parser.string_to_bool), ('Duration', None, float), ('SampleSize', 0, int), ('Channels', "", None), ('Publisher', "", None), ('Restrictions', "", None), ('Copyright', "", None))) def _parse_result(self, result): """Internal method to parse one Result node""" res = super(PodcastSearch, self)._parse_result(result) node = result.getElementsByTagName('Thumbnail') if node: res['Thumbnail'] = self._tags_to_dict(node[0], (('Url', None, None), ('Height', 0, int), ('Width', 0, int))) else: res['Thumbnail'] = None return res # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/dom/image.py0000644001174600001440000000633210330213577016603 0ustar leifusers"""DOM parser for Image search results Implement a simple DOM parser for the Yahoo Search Web Services image search APIs. """ __revision__ = "$Id: image.py,v 1.5 2005/10/27 18:07:59 zwoop Exp $" __version__ = "$Revision: 1.5 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 27 10:47:11 PDT 2005" from yahoo.search import dom, parser # # Image Search DOM parser # class ImageSearch(dom.DOMResultParser): """ImageSearch - DOM parser for Image Search Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Title - The title of the image file. Summary - Summary text associated with the image file. Url - The URL for the image file or stream. ClickUrl - The URL for linking to the image file. RefererUrl - The URL of the web page hosting the content. FileSize - The size of the file, in bytes. FileFormat - One of bmp, gif, jpg or png. Thumbnail - The URL of the thumbnail file. The following attributes are optional, and might not be set: Height - The height of the image in pixels. Width - The width of the image in pixels. Publisher - The creator of the image file. Restrictions - Provides any restrictions for this media object. Restrictions include noframe and noinline. Copyright - The copyright owner. The Thumbnail is in turn another dictionary, which will have the following keys: Url - URL of the thumbnail. Height - Height of the thumbnail, in pixels (optional). Width - Width of the thumbnail, in pixels (optional). Example: results = ws.parse_results(dom) for res in results: print "%s - %s bytes" % (res.Title, res.FileSize) """ def _init_res_fields(self): """Initialize the valid result fields.""" super(ImageSearch, self)._init_res_fields() self._res_fields.extend((('RefererUrl', None, None), ('FileSize', None, int), ('FileFormat', None, None), ('Height', 0, int), ('Width', 0, int), ('Publisher', "", None), ('Restrictions', "", None), ('Copyright', "", None))) def _parse_result(self, result): """Internal method to parse one Result node""" res = super(ImageSearch, self)._parse_result(result) node = result.getElementsByTagName('Thumbnail') if node: res['Thumbnail'] = self._tags_to_dict(node[0], (('Url', None, None), ('Height', 0, int), ('Width', 0, int))) else: raise parser.XMLError("ImageSearch DOM object has no Thumbnail") return res # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/dom/local.py0000644001174600001440000001450610571210413016606 0ustar leifusers"""DOM parser for Local search results Implement a simple DOM parser for the Yahoo Search Web Services local search APIs. """ __revision__ = "$Id: local.py,v 1.7 2007/02/28 05:20:11 zwoop Exp $" __version__ = "$Revision: 1.7 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 16:57:05 MST 2007" from yahoo.search import dom, parser from yahoo.search.parser import ResultDict # # News Search DOM parser # class LocalSearch(dom.DOMResultParser): """LocalSearch - DOM parser for Local Search This subclass of the SearchParser extends the parser with support for the Result Set Map Url. This adds an extra attribute results.result_set_map_url This attribute holds a URL pointing to a Yahoo Locals map with all the results shown on the map. Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Title - Name of the result. Address - Street address of the result. City - City in which the result is located. State - State in which the result is located. Phone - Phone number of the business, if known. Latitude - The latitude of the location. Longitude - The longitude of the location. Distance - The distance to the business or service. Url - The URL for the local file or stream. ClickUrl - The URL for linking to the detailed page. MapUrl - The URL of a map for the address. Categories - Contains all the categories in which this listing is classified. The following attributes are optional, and might not be set: Rating - Rating information (see below) BusinessUrl - The URL fo the business website, if known. BusinessClickUrl - The URL for linking to the business website, if known. The Rating dictionary contains the following keys: AverageRating - Average score of end-user ratings for the business or service. TotalRatings - The total number of ratings submitted for the business or service. TotalReviews - The total number of reviews submitted for the business or service. Reviews can be viewed at the location pointed to by the ClickUrl tag. LastReviewDate - The date of the last review submitted for the business or service unix timestamp format. LastReviewIntro - The first few words of the last review submitted for the business or service. Categories is a list of tuples with Name - Textual "name" value Id - Unique identifier (internal yahoo ID). Example: results = ws.parse_results() for res in results: print "%s is %s %s away" % (res.Title, res.Distance[0], res.Distance[1]) """ def __init__(self, service, res_dict=ResultDict): super(LocalSearch, self).__init__(service, res_dict) self._result_set_map_url = "" def parse_results(self, dom_object): """Specialized DOM parser for LocalSearch, to allow for the Map URL in the result. """ super(LocalSearch, self).parse_results(dom_object) try: url_node = dom_object.getElementsByTagName('ResultSetMapUrl') self._result_set_map_url = self._get_text(url_node[0].childNodes) except: raise parser.XMLError("DOM object has no ResultSetMapUrl") def _get_result_set_map_url(self): """Get the Yahoo Locals map with all the results.""" return self._result_set_map_url result_set_map_url = property(_get_result_set_map_url, None, None, "The Yahoo Locals map with all the results") ResultSetMapUrl = property(_get_result_set_map_url, None, None, "The Yahoo Locals map with all the results") def _init_res_fields(self): """Initialize the valid result fields.""" # Local search is special, and doesn't have all the standard # result fields ... self._res_fields = ((('Title', None, None), ('Address', None, None), ('City', None, None), ('State', None, None), ('Phone', None, None), ('Latitude', None, float), ('Longitude', None, float), ('Url', None, None), ('ClickUrl', None, None), ('MapUrl', None, None), ('BusinessUrl', "", None), ('BusinessClickUrl', "", None))) def _parse_result(self, result): """Internal method to parse one Result node""" res = super(LocalSearch, self)._parse_result(result) node = result.getElementsByTagName('Distance') if node: unit = node[0].getAttribute('unit') if unit == "": unit = "miles" res['Distance'] = (self._get_text(node[0].childNodes), unit) else: raise parser.XMLError("LocalSearch DOM object has no Distance") node = result.getElementsByTagName('Rating') if node: res['Rating'] = self._tags_to_dict(node[0], (('AverageRating', None, float), ('TotalRatings', None, int), ('TotalReviews', None, int), ('LastReviewDate', 0, int), ('LastReviewIntro', "", None))) else: res['Rating'] = None node = result.getElementsByTagName('Categories') if node: res['Categories'] = self._parse_list_node(node[0], 'Category') else: res['Categories'] = None return res # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/dom/news.py0000644001174600001440000000511310330041203016452 0ustar leifusers"""DOM parser for News search results Implement a simple DOM parser for the Yahoo Search Web Services news search APIs. """ __revision__ = "$Id: news.py,v 1.2 2005/10/27 02:59:15 zwoop Exp $" __version__ = "$Revision: 1.2 $" __author__ = "Leif Hedstrom " __date__ = "Wed Oct 26 15:02:17 PDT 2005" from yahoo.search import dom # # News Search DOM parser # class NewsSearch(dom.DOMResultParser): """NewsSearch - DOM parser for News Search Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Title - Title of the article. Summary - Summary of the text associated with the article. Url - The URL for the article. ClickUrl - The URL for linking to the article. NewsSource - The company that distributed the news article. NewsSourceUrl - The URL for the news source. Language - Language of the News article. PubslishDate - Publish date of the article. The following attributes are optional, and might not be set: ModificationDate - Date entry was modified. Thumbnail - The URL of the thumbnail file. If present, the Thumbnail value is in turn another dictionary, which will have these keys: Url - URL of the thumbnail. Height - Height of the thumbnail in pixels (optional). Width - Width of the thumbnail in pixels (optional). """ def _init_res_fields(self): """Initialize the valid result fields.""" super(NewsSearch, self)._init_res_fields() self._res_fields.extend((('NewsSource', None, None), ('NewsSourceUrl', None, None), ('Language', None, None), ('PublishDate', None, None), ('ModificationDate', "", None))) def _parse_result(self, result): """Internal method to parse one Result node""" res = super(NewsSearch, self)._parse_result(result) node = result.getElementsByTagName('Thumbnail') if node: res['Thumbnail'] = self._tags_to_dict(node[0], (('Url', None, None), ('Height', 0, int), ('Width', 0, int))) else: res['Thumbnail'] = None return res # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/dom/site.py0000644001174600001440000000534010571407172016466 0ustar leifusers"""DOM parser for Site Explorer results Implement a simple DOM parsers for the Yahoo Search Web Services site explorer APIs. This provides parser for the following classes: PageData - Shows a list of all pages belonging to a domain InlinkData - Shows the pages from other sites linking in to a page """ __revision__ = "$Id: site.py,v 1.3 2007/02/28 23:21:30 zwoop Exp $" __version__ = "$Revision: 1.3 $" __author__ = "Leif Hedstrom " __date__ = "Wed Feb 28 16:21:14 MST 2007" from yahoo.search import dom # # DOM parser for PageData and InlinkData (same schema) # class PageData(dom.DOMResultParser): """PageData - DOM parser for PageData results Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Title - The title of the web page. Url - The URL for the web page. ClickUrl - The URL for linking to the page. Example: results = ws.parse_results(dom) for res in results: print "%s - %s" % (res.Title, res.Url) """ def _init_res_fields(self): """Initialize the valid result fields.""" self._res_fields = [('Title', None, None), ('Url', None, None), ('ClickUrl', None, None)] # # DOM parser for UpdateNotification # class UpdateNotification(dom.DOMResultParser): """UpdateNotification - DOM parser for Site Update Notification The return value for this is always a list with one single element, a dictionary with Success - Did we succeed or not (True or False) Error - In case of a failure, the error message """ def parse_results(self, dom_object): """Internal method to parse one Result node""" res = self._res_dict() try: success = dom_object.getElementsByTagName('Success')[0] error = None except: success = None error = dom_object.getElementsByTagName('Error')[0] if success: res['Success'] = True res['Error'] = None elif error: res['Success'] = False try: message = error.getElementsByTagName('Message')[0] res['Error'] = self._get_text(message.childNodes) except: res['Error'] = "Unknown" else: res['Success'] = False res['Error'] = "Unknown" self._total_results_available = 1 self._total_results_returned = 1 self._first_result_position = 1 self._results.append(res) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/dom/term.py0000644001174600001440000000237210324600533016463 0ustar leifusers"""DOM parser for Term Extraction search results Implement a simple DOM parser for the Yahoo Search Web Services term extraction search APIs. """ __revision__ = "$Id: term.py,v 1.1 2005/10/17 01:41:47 zwoop Exp $" __version__ = "$Revision: 1.1 $" __author__ = "Leif Hedstrom " __date__ = "Sat Oct 15 15:44:48 PDT 2005" from yahoo.search import dom # # News Search DOM parser # class TermExtraction(dom.DOMResultParser): """TermExtraction - DOM parser for Term Extraction queries Return the list of words and phrases related to the context and the optional query string. The results from this search are slightly different compared to other services, it's just a simple list of words and phrases. """ def _parse_result_set(self, result_set): """Internal method to parse one Result node""" cnt = 0 for result in result_set.getElementsByTagName('Result'): cnt += 1 self._results.append(self._get_text(result.childNodes)) self._total_results_available = cnt self._total_results_returned = cnt if cnt > 0: self._first_result_position = 1 # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/dom/video.py0000644001174600001440000000736410330213577016635 0ustar leifusers"""DOM parser for Video search results Implement a simple DOM parser for the Yahoo Search Web Services video search APIs. """ __revision__ = "$Id: video.py,v 1.4 2005/10/27 18:07:59 zwoop Exp $" __version__ = "$Revision: 1.4 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 27 10:47:24 PDT 2005" from yahoo.search import parser, dom # # Video Search DOM parser # class VideoSearch(dom.DOMResultParser): """VideoSearch - DOM parser for Video Search Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Title - The title of the video file. Summary - Summary text associated with the video file. Url - The URL for the video file or stream. ClickUrl - The URL for linking to the video file. RefererUrl - The URL of the web page hosting the content. FileSize - The size of the file, in bytes. FileFormat - One of avi, flash, mpeg, msmedia, quicktime or realmedia. Duration - The duration of the video file in seconds. Streaming - Whether the video file is streaming or not. The following attributes are optional, and might not be set: Height - The height of the keyframe Yahoo! extracted from the video, in pixels. Width - The width of the keyframe Yahoo! extracted from the video, in pixels. Channels - Channels in the audio stream. Thumbnail - The URL of the thumbnail file. Publisher - The creator of the video file. Restrictions - Provides any restrictions for this media object. Restrictions include noframe and noinline. Copyright - The copyright owner. If present, the Thumbnail value is in turn another dictionary, which will have these keys: Url - URL of the thumbnail. Height - Height of the thumbnail in pixels (optional). Width - Width of the thumbnail in pixels (optional). Example: results = ws.parse_results(dom) for res in results: print "%s - %s bytes" % (res.Title, res.FileSize) """ def _init_res_fields(self): """Initialize the valid result fields.""" super(VideoSearch, self)._init_res_fields() self._res_fields.extend((('RefererUrl', None, None), ('FileSize', None, int), ('FileFormat', None, str), ('Height', 0, int), ('Width', 0, int), ('Streaming', None, parser.string_to_bool), ('Duration', None, float), ('Channels', "", str), ('Publisher', "", None), ('Restrictions', "", str), ('Copyright', "", None))) def _parse_result(self, result): """Internal method to parse one Result node""" res = super(VideoSearch, self)._parse_result(result) node = result.getElementsByTagName('Thumbnail') if node: res['Thumbnail'] = self._tags_to_dict(node[0], (('Url', None, None), ('Height', 0, int), ('Width', 0, int))) else: res['Thumbnail'] = None return res # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/dom/web.py0000644001174600001440000001026310330213577016274 0ustar leifusers"""DOM parser for Web search results Implement a simple DOM parsers for the Yahoo Search Web Services web search APIs. This provides parser for the following Web search classes: WebSearch - Web Search ContextSearch - Web Search with a context added RelatedSuggestion - Web Search Related Suggestion SpellingSuggestion - Web Search Spelling Suggestion """ __revision__ = "$Id: web.py,v 1.5 2005/10/27 18:07:59 zwoop Exp $" __version__ = "$Revision: 1.5 $" __author__ = "Leif Hedstrom " __date__ = "Thu Oct 27 10:46:03 PDT 2005" from yahoo.search import dom # # DOM parser for WebSearch and ContextSearch # class WebSearch(dom.DOMResultParser): """WebSearch - DOM parser for Web Search Each result is a dictionary populated with the extracted data from the XML results. The following keys are always available: Title - The title of the web page. Summary - Summary text associated with the web page. Url - The URL for the web page. ClickUrl - The URL for linking to the page. The following attributes are optional, and might not be set: ModificationDate - The date the page was last modified, Unix time. MimeType - The MIME type of the page. Cache - The URL of the cached result, and its size. If present, the Cache value is in turn another dictionary, which will have the following keys: Url - URL to cached data. Size - Size of the cached entry, in bytes. Example: results = ws.parse_results(dom) for res in results: if res.has_key('Cache'): print "Cache URL: ", res['Cache']['Url'] """ def _init_res_fields(self): """Initialize the valid result fields.""" super(WebSearch, self)._init_res_fields() self._res_fields.extend((('ModificationDate', "", None), ('MimeType', "", None))) def _parse_result(self, result): """Internal method to parse one Result node""" res = super(WebSearch, self)._parse_result(result) node = result.getElementsByTagName('Cache') if node: res['Cache'] = self._tags_to_dict(node[0], (('Url', None, None), ('Size', None, None))) else: res['Cache'] = None return res # # DOM parser for RelatedSuggestion # class RelatedSuggestion(dom.DOMResultParser): """RelatedSuggestion - DOM parser for Web Related Suggestions Simple related suggestions web service, returning a list of the candidate result strings. Note that the results from this service is slightly different compared to the other services, since each result can only be a string. """ def _parse_result_set(self, result_set): """Internal method to parse one Result node""" cnt = 0 for result in result_set.getElementsByTagName('Result'): cnt += 1 self._results.append(self._get_text(result.childNodes)) self._total_results_available = cnt self._total_results_returned = cnt if cnt > 0: self._first_result_position = 1 # # DOM parser for SpellingSuggestion # class SpellingSuggestion(dom.DOMResultParser): """SpellingSuggestion - DOM parser for Web Spelling Suggestions Simple spell checking web service, there can be only zero or one result from the query. Also note that the results from the search are slightly different compared to the other services, the one (possible) result is just simple string (not a dictionary). """ def _parse_result_set(self, result_set): """Internal method to parse one Result node""" cnt = 0 for result in result_set.getElementsByTagName('Result'): cnt += 1 self._results.append(self._get_text(result.childNodes)) self._total_results_available = cnt self._total_results_returned = cnt if cnt > 0: self._first_result_position = 1 # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/__init__.py0000644001174600001440000007257410671605343016520 0ustar leifusers"""Yahoo Search Web Services This module implements a set of classes and functions to work with the Yahoo Search Web Services. All results from these services are properly formatted XML, and this package facilitates for proper parsing of these result sets. Some of the features include: * Extendandable API, with replaceable backend XML parsers, and I/O interface. * Type and value checking on search parameters, including automatic type conversion (when appropriate and possible) * Flexible return format, including DOM objects, or fully parsed result objects You can either instantiate a search object directly, or use the factory function create_search() from the factory module. The supported classes of searches are: NewsSearch - News article search VideoSearch - Video and movie search ImageSearch - Image search LocalSearch - Local area search WebSearch - Web search ContextSearch - Web search with a context RelatedSuggestion - Web search Related Suggestion SpellingSuggestion - Web search Spelling Suggestion TermExtraction - Term Extraction service AlbumSearch - Find information about albums ArtistSearch - Information on a particular musical performer SongDownload - Find links to various song providers of a song PodcastSearch - Search for a Podcast site/feed SongSearch - Provide information about songs PageData - Shows a list of all pages belonging to a domain InlinkData - Shows the pages from other sites linking to a page The different sub-classes of search supports different sets of query parameters. For details on all allowed parameters, please consult the specific module documentation. Each of these parameter is implemented as an attribute of each respective class. For example, you can set parameters like: from yahoo.search.web import WebSearch app_id = "YahooDemo" srch = WebSearch(app_id) srch.query = "Leif Hedstrom" srch.results = 40 or, if you are using the factory function: from yahoo.search.factory import create_search app_id = "YahooDemo" srch = create_search("Web", app_id, query="Leif Hedstrom", results=40) if srch is not None: # srch object ready to use ... else: print "error" or, the last alternative, a combination of the previous two: import yahoo.search.web app_id = "YahooDemo" srch = web.WebSearch(app_id, query="Leif Hedstrom", results=40) To retrieve a certain parameter value, simply access it as any normal attribute: print "Searched for ", srch.query For more information on these parameters, and their allowed values, please see the official Yahoo Search Services documentation available at http://developer.yahoo.net/ Once the webservice object has been created, you can retrieve a parsed object (typically a DOM object) using the get_results() method: dom = srch.get_results() This DOM object contains all results, and can be used as is. For easier use of the results, you can use the built-in results factory, which will traverse the entire DOM object, and create a list of results objects. results = srch.parse_results(dom) or, by using the implicit call to get_results(): results = srch.parse_results() The default XML parser and results factories should be adequate for most users, so use the parse_results() when possible. However, both the XML parser and the results parser can easily be overriden. See the examples below for details. More information about the DOM parsers are available in the yahoo.search.dom module, and it's subclasses. EXAMPLES: This simple application will create a search object using the first command line argument as the "type" (e.g. "web" or "news"), and all subsequent arguments forms the query string: #!/usr/bin/python import sys from yahoo.search.factory import create_search service = sys.argv[1] query = " ".join(sys.argv[2:]) app_id = "YahooDemo" srch = create_search(service, app_id, query=query, results=5) if srch is None: srch = create_search("Web", app_id, query=query, results=5) dom = srch.get_results() results = srch.parse_results(dom) for res in results: url = res.Url summary = res['Summary'] print "%s -> %s" (summary, url) The same example using the PyXML 4DOM parser: #!/usr/bin/python import sys from yahoo.search.factory import create_search from xml.dom.ext.reader import Sax2 query = " ".join(sys.argv[2:]) srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5) if srch is not None: reader = Sax2.Reader() srch.install_xml_parser(reader.fromStream) . . . The last example will produce the same query, but uses an HTTP proxy for the request: #!/usr/bin/python import sys from yahoo.search.factory import create_search import urllib2 query = " ".join(sys.argv[2:]) srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5) if srch is not None: proxy = urllib2.ProxyHandler({"http" : "http://octopus:3128"}) opener = urllib2.build_opener(proxy) srch.install_opener(opener) . . . You can obviously "mix and match" as necessary here. I'm using the installer methods above for clarity, the APIs allows you to pass those custom handlers as arguments as well (see the documentation below). """ __revision__ = "$Id: __init__.py,v 1.19 2007/09/11 21:38:43 zwoop Exp $" __version__ = "$Revision: 1.19 $" __author__ = "Leif Hedstrom " __date__ = "Tue Sep 11 15:32:26 MDT 2007" import urllib import urllib2 import types import re import time from yahoo.search import debug __revision__ = "$Id: __init__.py,v 1.19 2007/09/11 21:38:43 zwoop Exp $" __version__ = "$Revision: 1.19 $" __author__ = "Leif Hedstrom " __date__ = "Thu Jul 7 14:22:16 PDT 2005" # # List of all sub-packages that we expose directly # __all__ = ["web", "news", "video", "image", "local", "term", "audio", "site"] # # List of all supported languages. # LANGUAGES = {'default':"english", 'ar':"arabic", 'bg':"bulgarian", 'ca':"catalan", 'szh':"chinese-simplified", 'tzh':"chinese-traditional", 'hr':"croatian", 'cs':"czech", 'da':"danish", 'nl':"dutch", 'en':"english", 'et':"estonian", 'fi':"finnish", 'fr':"french", 'de':"german", 'el':"greek", 'he':"hebrew", 'hu':"hungarian", 'is':"icelandic", 'id':"indonesian", 'it':"italian", 'ja':"japanese", 'ko':"korean", 'lv':"latvian", 'lt':"lithuanian", 'no':"norwegian", 'fa':"persian", 'pl':"polish", 'pt':"portuguese", 'ro':"romanian", 'ru':"russian", 'sk':"slovak", 'sr':"serbian", 'sl':"slovenian", 'es':"spanish", 'sv':"swedish", 'th':"thai", 'tr':"turkish"} # # List of all supported countries. # COUNTRIES = {'default':"any", 'any':"any", 'ar':"Argentina", 'au':"Australia", 'at':"Austria", 'be':"Belgium", 'br':"Brazil", 'ca':"Canada", 'cn':"China", 'cz':"Czechoslovakia", 'dk':"Denmark", 'fi':"Finland", 'fr':"France", 'de':"Germany", 'it':"Italy", 'jp':"Japan", 'kr':"Korea", 'nl':"Netherlands", 'no':"Norway", 'pl':"Poland", 'rf':"Russian Federation", 'es':"Spain",'se':"Sweden", 'ch':"Switzerland", 'tw':"Taiwan", 'uk':"United Kingdom", 'us':"United States"} # # List of all supported regions. # REGIONS = { 'default':"us", 'ar':"Argentina", 'au':"Australia", 'at':"Austria", 'br':"Brazil", 'ca':"Canada", 'ct':"Catalan", 'dk':"Denmark", 'fi':"Finland", 'fr':"France", 'de':"Germany", 'in':"India", 'id':"Indonesia", 'it':"Italy", 'my':"Malaysia", 'mx':"Mexico", 'nl':"Netherlands", 'no':"Norway", 'ph':"Phillipines", 'ru':"Russian Federation", 'sg':"Singapore", 'es':"Spain", 'se':"Sweden", 'ch':"Switzerland", 'th':"Thailand", 'uk':"United Kingdom & Ireland", 'us':"United States (yahoo.com)"} # # List of all Creative Content licenses. # CC_LICENSES = {'cc_any':"Any", 'cc_commercial':"Commercial", 'cc_modifiable':"Modifiable"} # # List of all subscription types # SUBSCRIPTIONS = {'cr':"Consumer Reports", 'ft':"FT.com", 'forrester':"Forrester Research", 'ieee':"IEEE publications", 'nejm':"New England Journal of Medicine", 'thestreet':"TheStreet.com", 'wsj':"Wall Street Journal"} # # Regular expressions # CALLBACK_REGEX = re.compile("^[a-zA-Z0-9\.\[\]\_]+$") # # Exceptions and error handling # class Error(Exception): """Base class for all Yahoo Web Services exceptions.""" class ParameterError(Error): """A parameter is missing, or has bad value""" pass class ServerError(Error): """The Yahoo server is unavailable.""" pass class ClassError(Error): """This can only occur if the APIs aren't installed or configured properly. If it happens, please contact the author.""" class SearchError(Error): """An exception/error occured in the search.""" def __init__(self, err): Error.__init__(self, err) self.msg = "unknown error" for line in err.readlines(): start = line.find("") if start > -1: stop = line.find("") if stop > -1: self.msg = line[start+9:stop] def __str__(self): return self.msg # # First a couple of base classes for the Search services. Most of them # are almost identical, so good candidates to sub-class one of these. # class _Search(debug.Debuggable, object): """Yahoo Search WebService - base class This class implements the core functionality of all Yahoo Search Services. """ NAME = "Search" SERVICE = "Search" PROTOCOL = "http" SERVER = "search.yahooapis.com" VERSION = "V1" METHOD = "GET" _NEXT_QID = 1 _RESULT_FACTORY = None def __init__(self, app_id, opener=None, xml_parser=None, result_factory=None, debug_level=0, **args): """The app_id is a required argument, the Yahoo search services will not accept requests without a proper app_id. A valid app_id is a combination of 8 - 40 characters, matching the regexp "^[a-zA-Z0-9 _()\[\]*+\-=,.:\\\@]{8,40}$" Please visit http://developer.yahoo.net/search/ to request an App ID for your own software or application. Four optional arguments can also be passed to the constructor: opener - Opener for urllib2 xml_parser - Function to parse XML (default: minidom) result_factory - Result factory class (default: none) debug_devel - Debug level (if any) All other "named" arguments are passed into as a dictionary to the set_params() method. The result factory is specific to the particular web service used, e.g. the different Yahoo Search services will each implement their own factory class. Both of these settings can be controlled via their respective install method (see below). """ super(_Search, self).__init__(debug_level) self._service = {'name' : self.NAME, 'protocol' : self.PROTOCOL, 'server' : self.SERVER, 'version' : self.VERSION, 'service' : self.SERVICE} self._app_id = None self.app_id = app_id self._require_oneof_params = [] self._urllib_opener = opener self._xml_parser = xml_parser if result_factory: self._result_factory = result_factory else: self._result_factory = self._RESULT_FACTORY if self._xml_parser is None: import xml.dom.minidom self._xml_parser = xml.dom.minidom.parse self._default_xml_parser = self._xml_parser self._qid = self._NEXT_QID self._NEXT_QID += 1 # All Search APIs now supports "output" and "callback". self._valid_params = { "output" : (types.StringTypes, "xml", str.lower, ("xml", "json", "php"), None, False), "callback" : (types.StringTypes, None, None, lambda x: CALLBACK_REGEX.match(x) is not None, "the characters A-Z a-z 0-9 . [] and _.", False), } self._init_valid_params() self._params = {} if args: self.set_params(args) # Implement the attribute handlers, to avoid confusion def __setattr__(self, name, value): if (hasattr(getattr(self.__class__, name, None), '__set__') or name[0] == '_'): super(_Search, self).__setattr__(name, value) else: # Special case for "output", since we need to disable the # XML parser as well. if (name == "output"): if (value in ("json", "php")): self._xml_parser = None else: self._xml_parser = self._default_xml_parser self.set_param(name, value) def __getattr__(self, name): if (hasattr(getattr(self.__class__, name, None), '__get__') or name[0] == '_'): return super(_Search, self).__getattr__(name) else: return self.get_param(name) def _init_valid_params(self): """Initialize the valid params, this is a virtual function and should be overriden properly.""" err = """Yahoo Search Service class %s must implement a \ _init_valid_params()""" % (self.svc_name) raise ClassError(err) def reset(self): """Reset all the parameter values for the object instance.""" self._params = {} def _get_svc_name(self): """Get the descriptive service name.""" return self._service['name'] def _set_svc_name(self, value): """Set the descriptive service name.""" self._service['name'] = value svc_name = property(_get_svc_name, _set_svc_name, None, "Descriptive name of the service") def _get_svc_protocol(self): """Get the service protocol (e.g. HTTP).""" return self._service['protocol'] def _set_svc_protocol(self, value): """Set the service protocol (must be supported).""" self._service['protocol'] = value svc_protocol = property(_get_svc_protocol, _set_svc_protocol, None, "Service protocol (e.g. HTTP)") def _get_svc_service(self): """Get the URL path for the service.""" return self._service['service'] def _set_svc_service(self, value): """Set the URL path for the service.""" self._service['service'] = value svc_service = property(_get_svc_service, _set_svc_service, None, "Service path") def _get_svc_server(self): """Get the service server name or IP.""" return self._service['server'] def _set_svc_server(self, value): """Set the service server name or IP.""" self._service['server'] = value svc_server = property(_get_svc_server, _set_svc_server, None, "Service server name or IP") def _get_svc_version(self): """Get the service version string.""" return self._service['version'] def _set_svc_version(self, value): """Set the service version string.""" self._service['version'] = value svc_version = property(_get_svc_version, _set_svc_version, None, "Service version string") def _get_app_id(self): """Get the application ID.""" return self._app_id def _set_app_id(self, app_id): """Set the application ID, which is required.""" if isinstance(app_id, types.StringTypes): self._app_id = app_id else: raise ValueError("""`app_id' can contain \ a-zA-Z0-9 _()\[\]*+\-=,.:\\\@ (8-40 char long)""") app_id = property(_get_app_id, _set_app_id, None, "Application ID (issued by Yahoo), same ass appid") appid = property(_get_app_id, _set_app_id, None, "Application ID (issued by Yahoo)") # Manage service parameters def set_params(self, args): """Set one or several query parameters from a dictionary""" for (param, value) in args.items(): self.set_param(param, value) def get_param(self, param): """Get the value of a query parameter, or the default value if unset""" if not self._valid_params.has_key(param): err = "`%s' is not a valid parameter for `%s'" % ( param, self._service['name']) raise ParameterError(err) if self._params.has_key(param): return self._params[param] else: return self._valid_params[param][1] # # The valid_params is a list with the following elements: # [0] - Allowed data type (e.g. types.StringTypes) # [1] - Default value (e.g. 10) # [2] - Data conversion/casting function (e.g. int) # [3] - List of valid values -or- validation function # [4] - Help text for error messages # [5] - Boolean indicating if the parameter is required # def set_param(self, param, value): """Set the value of a query parameter""" if not self._valid_params.has_key(param): err = "`%s' is not a valid parameter for `%s'" % ( param, self._service['name']) raise ParameterError(err) pinfo = self._valid_params[param] if value is None: err = "`%s' can not have an undefined value" % (param) raise ValueError(err) # Do explicit type conversions (if possible) if pinfo[2] is not None: try: if isinstance(value, (types.ListType, types.TupleType)): value = [pinfo[2](val) for val in value] # ToDo XXX: Should we make sure each value is unique? else: value = pinfo[2](value) except ValueError: value = value # Check the type validity of the value err = False if isinstance(value, (types.ListType, types.TupleType)): for val in value: if not isinstance(val, pinfo[0]): err = True break elif not isinstance(value, pinfo[0]): err = True if err: raise TypeError("`%s' only takes values of type %s" % ( param, str(pinfo[0]))) # Check validity of the value (if possible) err = False if callable(pinfo[3]): if isinstance(value, (types.ListType, types.TupleType)): for val in value: if not pinfo[3](val): err = True break else: if not pinfo[3](value): err = True elif isinstance(pinfo[3], (types.TupleType, types.ListType)): if isinstance(value, (types.ListType, types.TupleType)): for val in value: if not val in pinfo[3]: err = True break elif not value in pinfo[3]: err = True if err: if pinfo[4] is not None: hlp = pinfo[4] else: hlp = str(pinfo[3]) raise ValueError("`%s' only handles values in: %s" % (param, hlp)) # Update the parameter only if it's different from the default if value != pinfo[1]: self._params[param] = value elif self._params.has_key(param): self._params.pop(param) def get_valid_params(self): """Return a list of all valid parameters for this search""" return self._valid_params.keys() def missing_params(self): """Validate that the search object is propertly setup with all required parameters etc. This is called automatically before a search is actually performed, but you can also call it manually if desired. It will return a list of zero or more paramters that are missing. """ ret = [] for (param, pinfo) in self._valid_params.items(): if pinfo[5]: if (not self._params.has_key(param) or not self._params[param]): ret.append(param) # Check "require_oneof" list, if necessary if len(ret) == 0: for param in self._require_oneof_params: if self._params.has_key(param): return [] return self._require_oneof_params else: return ret def _get_languages(self): """Get the list of all supported languages.""" return LANGUAGES languages = property(_get_languages, None, None, "List of all supported languages") def _get_countries(self): """Get the list of all supported contry codes.""" return COUNTRIES countries = property(_get_countries, None, None, "List of all supported county codes") def _get_regions(self): """Get the list of all supported region codes.""" return REGIONS regions = property(_get_regions, None, None, "List of all supported region codes") def _get_cc_licenses(self): """Get the list of all supported CC licenses.""" return CC_LICENSES cc_licenses = property(_get_cc_licenses, None, None, "List of all supported Creative Commons licenses") def _get_subscriptions(self): """Get the list of supported premium subscriptions.""" return SUBSCRIPTIONS subscriptions = property(_get_subscriptions, None, None, "List of all supported premium subscriptions") # Manage (install) the Opener, XML parser and result factory (parser) def install_opener(self, opener): """Install a URL opener (for use with urllib2), overriding the default opener. This is rarely required. """ self._urllib_opener = opener def install_xml_parser(self, xml_parser): """Install an XML parser that will be used for all results for this object. The parser is expected to "read" the data from the supplied stream argument. To uninstall the parser (e.g. to make sure we return raw XML data) simply call this method with an argument of None. """ self._default_xml_parser = xml_parser self._xml_parser = xml_parser def install_result_factory(self, result_factory): """Install a python class (not an instance!) that should be used as a factory for creating result(s) objects. """ self._result_factory = result_factory # Methods working on connection handling etc. def encode_params(self): """URL encode the list of parameter values.""" params = self._params.copy() params.update({'appid' : self._app_id}) return urllib.urlencode(params, 1) def get_url(self, with_params=True): """Return the URL for this request object""" url = "%s://%s/%s/%s/%s" % (self._service['protocol'], self._service['server'], self._service['service'], self._service['version'], self._service['name']) if with_params: return "%s?%s" % (url, self.encode_params()) else: return url def open(self, opener=None, retries=2): """Open a connection to the webservice server, and request the URL. The return value is a "stream", which can be read calling the read(), readline() or readlines() methods. If you override this method, please make sure to call the missing_params() method before you try to send a request to the Web server. """ missing = self.missing_params() if missing: if len(missing) > 1: err = "Missing these parameters: `%s'" % str(missing) else: err = "Missing the parameter `%s'" % missing[0] raise ParameterError(err) if opener is not None: urllib2.install_opener(opener) elif self._urllib_opener is not None: urllib2.install_opener(self._urllib_opener) if self.METHOD == "POST": url = self.get_url(with_params=False) data = self.encode_params() else: url = self.get_url(with_params=True) data = None self._debug_msg("Opening URL = %s", debug.DEBUG_LEVELS['HTTP'], url) if data: self._debug_msg("POSTing data = %s", debug.DEBUG_LEVELS['HTTP'], data) try: resp = urllib2.urlopen(url, data) except urllib2.HTTPError, err: if err.code == 503: retries -= 1 if retries >= 0: self._debug_msg("Retrying open(), URL = %s", debug.DEBUG_LEVELS['HTTP'], url) time.sleep(0.05) return self.open(opener, retries=retries) raise ServerError("""Internal WebService error, temporarily \ unavailable""") else: raise SearchError(err) raise ServerError("WebService server unavailable") return resp def get_results(self, stream=None, xml_parser=None, close=True): """Read the stream (if provided) and either return the raw XML, or send the data to the provided XML parser for further processing. If no stream is provided, it will call the open() method using the default opener. The stream will be closed upon return from this method, unless the close=False is passed as an argument. """ self._debug_msg("VALID_PARAMS = %s", debug.DEBUG_LEVELS['PARAMS'], self._valid_params.keys()) if stream is None: stream = self.open() if xml_parser is None: xml_parser = self._xml_parser if xml_parser is not None: res = xml_parser(stream) try: self._debug_msg("XML results are:\n%s", debug.DEBUG_LEVELS['RAWXML'], res.toprettyxml()) except AttributeError: pass else: res = "".join(stream.readlines()) if close: stream.close() return res def parse_results(self, xml=None): """Get the result from the request, and instantiate the appropriate result class. This class will be populated with all the data from the XML object. """ if self._result_factory is None: return None if xml is None: xml = self.get_results() res = self._result_factory(service=self) res.parse_results(xml) return res def _get_debug_level(self): """Get the current debug level.""" return self._debug_level def _set_debug_level(self, level): """Set the new debug level to be used.""" self._debug_level = level debug_level = property(_get_debug_level, _set_debug_level, None, "Set and modify the debug level") # # Basic parameters, supported by all regular search classes # class _BasicSearch(_Search): """Yahoo Search WebService - basic params service Setup the basic CGI parameters that all (normal) search services supports. This is used by most services (classes) to provision for the basic parameters they all use. """ def _init_valid_params(self): """Initialize the set of valid parameters.""" self._valid_params.update({ "query" : (types.StringTypes, None, None, None, None, True), "results" : (types.IntType, 10, int, lambda x: x > -1 and x < 51, "the range 1 to 50", False), "start" : (types.IntType, 1, int, lambda x: x > -1 and x < 1001, None, False), }) # # Common search parameters, shared by several packages, but not all. # class _CommonSearch(_Search): """Yahoo Search WebService - common params service Several search services share a few non-basic parameters, so this sub-class of _BasicParams saves some typing. """ def _init_valid_params(self): """Initialize the set of valid parameters.""" self._valid_params.update({ "query" : (types.StringTypes, None, None, None, None, True), "results" : (types.IntType, 10, int, lambda x: x > -1 and x < 51, "the range 1 to 50", False), "start" : (types.IntType, 1, int, lambda x: x > -1 and x < 1001, None, False), "type" : (types.StringTypes, "any", str.lower, ("all", "any", "phrase"), None, False), "adult_ok" : (types.IntType, None, int, (1,), None, False), }) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/audio.py0000644001174600001440000003551510571210411016037 0ustar leifusers"""yahoo.search.audio - Audio Search services module This module implements the the Audio Search web service, to do search queries on various audio formats. The supported classes of web searches are: ArtistSearch - Information on a particular musical performer AlbumSearch - Find information about albums SongSearch - Provide information about songs SongDownloadLocation - Find links to various providers of a song PodcastSearch - Search for a Podcast site/feed An application ID (appid) is always required when instantiating a search object. In addition, each search class takes different set of parameters, as defined by this table: AlbumSearch ArtistSearch SongSearch SongDownloadLocation ----------- ------------ ---------- -------------------- type [X] [X] [X] . results [X] [X] [X] [X] start [X] [X] [X] [X] artist [X] [X] [X] . artistid [X] [X] [X] . album [X] . [X] . albumid [X] . [X] . song . . [X] [X] songid . . [X] . source . . . [X] output [X] [X] [X] [X] callback [X] [X] [X] [X] Each of these parameter is implemented as an attribute of each respective class. For example, you can set parameters like: from yahoo.search.audio import AlbumSearch srch = AlbumSearch(app_id="YahooDemo") srch.album = "Like" srch.results = 40 for res in srch.parse_results(): print res.Artist The PodcastSearch service takes a different set of parameters, see the documentation for this class for further details. """ import types import yahoo.search import yahoo.search.dom.audio __revision__ = "$Id: audio.py,v 1.9 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.9 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 14:08:31 MST 2007" # # Song download sources. XXX ToDo: These need descriptions. # DOWNLOAD_SOURCES = {'audiolunchbox':"", 'artistdirect':"", 'buymusic':"", 'dmusic':"", 'emusic':"", 'epitonic':"", 'garageband':"", 'itunes':"", 'yahoo':"", 'livedownloads':"", 'mp34u':"", 'msn':"", 'musicmatch':"", 'mapster':"", 'passalong':"", 'rhapsody':"", 'soundclick':"", 'theweb':""} # # Base class for some Audio Search classes # class _Audio(yahoo.search._Search): """Yahoo Search WebService - Common Audio Search parameters Setup the basic CGI parameters for some Audio Search services Since many of these services do not take a query argument, we can't subclass the Basic or Common search classes. """ def _init_valid_params(self): """Initialize the set of valid parameters.""" self._valid_params.update({ "artist" : (types.StringTypes, None, None, None, None, False), "artistid" : (types.StringTypes, None, None, None, None, False), "type" : (types.StringTypes, "all", str.lower, ("all", "any", "phrase"), None, False), "results" : (types.IntType, 10, int, lambda x: x > -1 and x < 51, "the range 1 to 50", False), "start" : (types.IntType, 1, int, lambda x: x > -1 and x < 1001, "the range 1 to 1000", False), }) def _get_download_sources(self): """Get the list of all supported download sources.""" return DOWNLOAD_SOURCES download_sources = property(_get_download_sources, None, None, "List of all supported download sources") # # AlbumSearch class # class AlbumSearch(_Audio): """AlbumSearch - perform a Yahoo Album Search This class implements the Album Search web service APIs, which allows you to find information on music albums. Supported parameters are: results - The number of results to return (1-50). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. artist - The artist or partial artist string to search for (UTF-8 encoded). artistid - The specific id for an artist. album - The album name or partial album string to search for (UTF-8 encoded). albumid - The specific id for an album. Ids are internal to the Music Search Service and will be returned with album references. At least one of artist, artistid, album or albumid is required. type - The kind of search to submit: * "all" returns results with all query terms. * "any" resturns results with one or more of the query terms. * "phrase" returns results containing the query terms as a phrase. output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Full documentation for this service is available at: http://developer.yahoo.net/search/audio/V1/albumSearch.html """ NAME = "albumSearch" SERVICE = "AudioSearchService" _RESULT_FACTORY = yahoo.search.dom.audio.AlbumSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(AlbumSearch, self)._init_valid_params() self._valid_params.update({ "album" : (types.StringTypes, None, None, None, None, False), "albumid" : (types.StringTypes, None, None, None, None, False), }) self._require_oneof_params = ["artist", "artistid", "album", "albumid"] # # ArtistSearch class # class ArtistSearch(_Audio): """ArtistSearch - perform a Yahoo Artist Search This class implements the Artist Search web service APIs. Allowed parameters are: results - The number of results to return (1-50). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. artist - The artist or partial artist string to search for (UTF-8 encoded). artistid - The specific id for an artist. Ids are internal to the Music Search Service and will be returned with artist references. One of artist or artistid is always required. type - The kind of search to submit: * "all" returns results with all query terms. * "any" resturns results with one or more of the query terms. * "phrase" returns results containing the query terms as a phrase. output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Full documentation for this service is available at: http://developer.yahoo.net/search/audio/V1/artistSearch.html """ NAME = "artistSearch" SERVICE = "AudioSearchService" _RESULT_FACTORY = yahoo.search.dom.audio.ArtistSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(ArtistSearch, self)._init_valid_params() self._require_oneof_params = ["artist", "artistid"] # # SongSearch class # class SongSearch(_Audio): """AlbumSearch - perform a Yahoo Album Search This class implements the Album Search web service APIs, which allows you to find information on music albums. Supported parameters are: results - The number of results to return (1-50). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. artist - The artist or partial artist string to search for (UTF-8 encoded). artistid - The specific id for an artist. album - The album name to search for (UTF-8 encoded). albumid - The specific id for an album. song - The song title to search for (UTF-8 encoded). songid - The specific id for a song. At least one of artist, artistid, album, albumid, song or songid is required. type - The kind of search to submit: * "all" returns results with all query terms. * "any" resturns results with one or more of the query terms. * "phrase" returns results containing the query terms as a phrase. output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Full documentation for this service is available at: http://developer.yahoo.net/search/audio/V1/songSearch.html """ NAME = "songSearch" SERVICE = "AudioSearchService" _RESULT_FACTORY = yahoo.search.dom.audio.SongSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(SongSearch, self)._init_valid_params() self._valid_params.update({ "album" : (types.StringTypes, None, None, None, None, False), "albumid" : (types.StringTypes, None, None, None, None, False), "song" : (types.StringTypes, None, None, None, None, False), "songid" : (types.StringTypes, None, None, None, None, False), }) self._require_oneof_params = ["artist", "artistid", "album", "albumid", "song", "songid"] # # SongDownlocaLocation class # class SongDownloadLocation(_Audio): """SongDownloadLocation - find places to download songs This class implements the Song Download Location web service APIs. Allowed parameters are: songid - The specific id for a song. results - The number of results to return (1-50). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. source - The source of the download. You may specify multiple values, e.g. ["yahoo", "itunes"]. results - The number of results to return (1-50). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. Full documentation for this service is available at: http://developer.yahoo.net/search/audio/V1/artistSearch.html """ NAME = "songDownloadLocation" SERVICE = "AudioSearchService" _RESULT_FACTORY = yahoo.search.dom.audio.SongDownloadLocation def _init_valid_params(self): """Initialize the set of valid parameters.""" self._valid_params.update({ "songid" : (types.StringTypes, None, None, None, None, True), "results" : (types.IntType, 10, int, lambda x: x > -1 and x < 51, "the range 1 to 50", False), "start" : (types.IntType, 1, int, lambda x: x > -1 and x < 1001, "the range 1 to 1000", False), "source" : (types.StringTypes, [], str.lower, self.download_sources.keys(), None, False), }) # # PodcastSearch class # class PodcastSearch(yahoo.search._CommonSearch): """PodcastSearch - perform a Yahoo Podcast Search This class implements the Podcast Search web service APIs. Allowed parameters are: query - The query to search for (UTF-8 encoded). type - The kind of search to submit (all, any or phrase). results - The number of results to return (1-50). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. format - Specifies the kind of audio file to search for. adult_ok - The service filters out adult content by default. Enter a 1 to allow adult content. output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Supported formats are all - All formats (default) aiff - AIFF midi - MIDI file mp3 - MP3 (MPEG-3) format msmedia - Microsoft media quicktime - Apple QuickTime realmedia - Real media wav - Wave file other - Other Full documentation for this service is available at: http://developer.yahoo.net/audio/V1/podcastSearch.html """ NAME = "podcastSearch" SERVICE = "AudioSearchService" _RESULT_FACTORY = yahoo.search.dom.audio.PodcastSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(PodcastSearch, self)._init_valid_params() self._valid_params.update({ "format" : (types.StringTypes, "any", str.lower, ("all", "any", "aiff", "midi", "msmedia", "quicktime", "realmedia", "wav", "other"), None, False), }) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/debug.py0000644001174600001440000000376110327763733016045 0ustar leifusers"""yahoo.search.debug - Debugging utilities This module defines and provides some debugging utilities that can be used when you encounter problems with the search APIs. Most interesting is the various debugging levels: HTTP - Various HTTP protocol related information. PARAMS - Show debugging information about CGI parameters. PARSING - Show parsing processing. RAWXML - Show the raw XML. ALL - Show everything. """ import sys __revision__ = "$Id: debug.py,v 1.7 2005/10/26 20:32:27 zwoop Exp $" __version__ = "$Revision: 1.7 $" __author__ = "Leif Hedstrom " __date__ = "Wed Oct 26 11:15:36 PDT 2005" # Debug levels, 32 bits of "features" DEBUG_LEVELS = { 'ALL' : 2**32-1, 'HTTP' : 2**0, 'PARAMS': 2**1, 'PARSING' : 2**2, # These are very verbose 'RAWXML' : 2**31, } # # Simple class to use instead of "object", to enable # debugging messages etc. # class Debuggable(object): """Debuggable - Simple "base" class to implement debugging. You should use this instead of object as a base class. The only useful member function is _debug_msg, intentionally made private to avoid exposing it in docs and APIs. """ def __init__(self, debug_level=0): self._debug_level = debug_level def _debug_msg(self, msg, level, *args): """Produce a debug message, if the current debug level is higher than the requested level. """ if self._debug_level & level: sys.stderr.write("[debug: ") text = msg % args if isinstance(text, unicode): try: text = text.encode("utf-8") except UnicodeError: text = msg + " (encode() failed!)" sys.stderr.write(text) sys.stderr.write("]\n") # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/factory.py0000644001174600001440000001010410671605343016405 0ustar leifusers"""Search Factory - simple API to create search objects This module implements a few convenience functions to make it easy and safe to create search objects. This is not the most efficient way to use the web services, but it's convenient. Future releases of the APIs will hopefully also make this factory implementation less cumbersome. """ from yahoo.search import * __revision__ = "$Id: factory.py,v 1.11 2007/09/11 21:38:43 zwoop Exp $" __version__ = "$Revision: 1.11 $" __author__ = "Leif Hedstrom " __date__ = "Tue Sep 11 15:33:28 MDT 2007" # # This is a "convenience" dictionary, providing a (very) short # description of all available Search classes. The factory function # uses this dictionary to make a "simple" interface to instantiate # and configure a search object in one call. # SERVICES = { 'video':(video.VideoSearch, "Video Search"), 'image':(image.ImageSearch, "Image Search"), 'web':(web.WebSearch, "Web Search"), 'context':(web.ContextSearch, "Contextual Web Search"), 'related':(web.RelatedSuggestion, "Web Search Related Suggestion"), 'spelling':(web.SpellingSuggestion, "Web Search Spelling Suggestion"), 'news':(news.NewsSearch, "News Search"), 'local':(local.LocalSearch, "Local Search"), 'term':(term.TermExtraction, "Term extraction service"), 'artist':(audio.ArtistSearch, "Information on a musical performer"), 'album':(audio.AlbumSearch, "Search for a specific music album"), 'song':(audio.ArtistSearch, "Search for a music song"), 'songdownload':(audio.SongDownloadLocation, "Find song download locations"), 'podcast':(audio.PodcastSearch, "Search for a Podcast site/feed"), 'pagedata':(site.PageData, "Find all pages belonging to a domain"), 'inlinkdata':(site.InlinkData, "Show pages linking to a specific page"), } # # Create a search object, using some convenient argument "parsing" # def create_search(name, app_id, xml_parser=None, result_factory=None, debug_level=0, **args): """Create a Yahoo Web Services object, and configure it This is a simple "factory" function to instantiate and configure a Yahoo Web Services object. For example: app_id = "YahooDemo" srch = create_search("Web", app_id, query="Yahoo", results=4) if srch is not None: dom = srch.get_results() The first argument is one of the following "classes" of searches: Web - Web search Context - Contextual Web search Related - Web search Related Suggestions Spelling - Web search Spelling Suggestions Video - Video search Image - Image search News - News article search Local - Local search Term - Term extraction service Artist - Find information on a musical performer Album - Find information about albums Song - Provide information about songs SongDownload - Find links to various song providers of a song Podcast - Search for a Podcast site/feed PageData - Find all pages belonging to a domain InlinkData - Show pages linking to a specific page The second argument, app_id (or appid), is an application specific identifier, provided by Yahoo. The web services will not accept any requests without a proper AppID. All other arguments must be valid named arguments, and the allowed set of parameters depends on the specific class of search being instantiated. See http://developer.yahoo.net/search/ for a more comprehensive list and documentation of allowed parameters for all types of searches. """ name = name.lower() if not SERVICES.has_key(name): return None obj = SERVICES[name][0](app_id, xml_parser=xml_parser, result_factory=result_factory, debug_level=debug_level) if obj and args: obj.set_params(args) return obj # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/image.py0000644001174600001440000000724310571210411016015 0ustar leifusers"""yahoo.search.image - Image Search services module This module implements the the Image Search web service, to do search queries on various image formats. There is currently only one class implemented, ImageSearch. An application ID (appid) is always required when instantiating a search object. Additional parameters are documented in the ImageSearch class. Example: from yahoo.search.image import ImageSearch srch = ImageSearch(app_id="YahooDemo", query="Yahoo") srch.results = 10 for res in srch.parse_results(): print res.Thumbnail.Url """ import types import yahoo.search import yahoo.search.dom.image __revision__ = "$Id: image.py,v 1.4 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.4 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 14:51:16 MST 2007" # # ImageSearch class # class ImageSearch(yahoo.search._CommonSearch): """ImageSearch - perform a Yahoo Image Search This class implements the Image Search web service APIs. Allowed parameters are: query - The query to search for (UTF-8 encoded). type - The kind of search to submit (all, any or phrase). results - The number of results to return (1-50). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. type - The kind of search to submit: * "all" returns results with all query terms. * "any" resturns results with one or more of the query terms. * "phrase" returns results containing the query terms as a phrase. format - Specifies the kind of image file to search for. adult_ok - The service filters out adult content by default. Enter a 1 to allow adult content. coloration - The coloration type of the images (default, bw or color). site - A domain to restrict your searches to (e.g. www.yahoo.com). You may submit up to 30 values (e.g. ["www.yahoo.com", "www.cnn.com"]). output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Supported formats are any - Any format bmp - Bitmap (windows) gif - GIF jpeg - JPEG png - PNG Full documentation for this service is available at: http://developer.yahoo.net/image/V1/imageSearch.html """ NAME = "imageSearch" SERVICE = "ImageSearchService" _RESULT_FACTORY = yahoo.search.dom.image.ImageSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(ImageSearch, self)._init_valid_params() self._valid_params.update({ "format" : (types.StringTypes, "any", str.lower, ("all", "any", "bmp", "gif", "jpeg", "png"), None, False), "coloration" : (types.StringTypes, "default", str.lower, ("default", "bw", "color", "colour"), None, False), "site" : (types.StringTypes, [], None, None, "a list of up to 30 domains", False), }) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/local.py0000644001174600001440000001463110571210411016024 0ustar leifusers"""yahoo.search.local - Local Search services module This module implements the the Local Search web service, to do search queries on various local formats. There is currently only one class implemented, LocalSearch. An application ID (appid) is always required when instantiating a search object. Additional parameters are documented in the LocalSearch class. Example: from yahoo.search.local import LocalSearch srch = LocalSearch(app_id="YahooDemo", zip="94019", query="BevMo") srch.results = 1 for res in srch.parse_results(): print res.MapUrl """ import types import yahoo.search import yahoo.search.dom.local __revision__ = "$Id: local.py,v 1.4 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.4 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 17:04:24 MST 2007" # # LocalSearch class # class LocalSearch(yahoo.search._BasicSearch): """LocalSearch - perform a Yahoo Local Search This class implements the Local Search web service APIs. Allowed parameters are: query - The query to search for. Using a query of "*" returns all values that match other criteria in the search (category, radius, and so on). listing_id - The id associated with a specific business listing. It corresponds with the id attribute of Result entities. At least one of query or listing id must be specified. results - The number of results to return (1-20). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. sort - Sorts the results by the chosen criteria. radius - How far from the specified location to search for the query terms. street - Street name. The number is optional. city - City name. state - The United States state. You can spell out the full state name or you can use the two-letter abbreviation. zip - The five-digit zip code, or the five-digit code plus four-digit extension. location - Free form field for location (see below). latitude - Latitude of the starting location (-90.0 - 90.0). longitude - Longitude of the starting location (-180.0 - 180.0). category - The id of a category to search in. This id corresponds to the id attribute of the Category entity. If you specify multiple categories, results are taken from entries that appear in all of the specified categories. omit_category - The id of a category to omit results from. Multiple categories may be omitted, and a result will not be returned if it appears in any of the specified categories. minimum_rating - The minimum average rating (on a five point scale) for a result. If this is specified, no results without ratings will be returned. output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. If both latitude and longitude are specified, they will take priority over all other location data. If only one of latitude or longitude is specified, both will be ignored. The sort parameter is one of relevance title distance rating The free text of the location parameter can hold any of * city, state * city,state, zip * zip * street, city, state * street, city, state, zip * street, zip If location is specified, it will take priority over the individual fields in determining the location for the query. City, state and zip will be ignored. Full documentation for this service is available at: http://developer.yahoo.net/search/local/V3/localSearch.html """ NAME = "localSearch" SERVICE = "LocalSearchService" VERSION = "V3" SERVER = "local.yahooapis.com" _RESULT_FACTORY = yahoo.search.dom.local.LocalSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(LocalSearch, self)._init_valid_params() self._valid_params.update({ "query" : (types.StringTypes, None, None, None, None, False), "listing_id" : (types.StringTypes, None, None, None, None, False), "results" : (types.IntType, 10, int, range(1, 21), "the range 1 to 20", False), "sort" : (types.StringTypes, "relevance", str.lower, ("relevance", "title", "distance", "rating"), None, False), "radius" : (types.FloatType, None, float, None, None, False), "street" : (types.StringTypes, None, None, None, None, False), "city" : (types.StringTypes, None, None, None, None, False), "state" : (types.StringTypes, None, None, None, None, False), "zip" : (types.StringTypes, None, None, None, None, False), "location" : (types.StringTypes, None, None, None, None, False), "latitude" : (types.FloatType, None, float, lambda x: x > (-90) and x < 90, "-90 < val < 90", False), "longitude" : (types.FloatType, None, float, lambda x: x > (-180) and x < 180, "-180 < val < 180", False), "category" : (types.IntType, [], int, None, "a list of integers", False), "omit_category" : (types.IntType, [], int, None, "a list of integers", False), "minimum_rating" : (types.IntType, None, int, range(1, 6), "the range 1 to 5", False), }) self._require_oneof_params = ["query", "listing_id"] # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/news.py0000644001174600001440000000645510571210411015713 0ustar leifusers"""yahoo.search.news - News Search service module This module implements the News Search web services, searching news articles. There is currently only one class implemented, NewsSearch. An application ID (appid) is always required when instantiating a search object. Additional parameters are documented in the NewsSearch class. Example: from yahoo.search.news import NewsSearch srch = NewsSearch(app_id="YahooDemo", query="Yahoo") srch.results = 10 for res in srch.parse_results(): print res.NewsSource """ import types import yahoo.search import yahoo.search.dom.news __revision__ = "$Id: news.py,v 1.4 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.4 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 17:20:45 MST 2007" # # NewsSearch class # class NewsSearch(yahoo.search._BasicSearch): """NewsSearch - perform a Yahoo News Search This class implements the News Search web service APIs. Allowed parameters are: query - The query to search for. type - The kind of search to submit: * "all" returns results with all query terms. * "any" resturns results with one or more of the query terms. * "phrase" returns results containing the query terms as a phrase. results - The number of results to return (1-50). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. sort - Sort articles by relevance ('rank') or most-recent ('date'). Default is by relevance. language - The language the results are written in. site - A domain to restrict your searches to (e.g. www.yahoo.com). You may submit up to 30 values (e.g. ["www.yahoo.com", "www.cnn.com"]). output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Full documentation for this service is available at: http://developer.yahoo.net/news/V1/newsSearch.html """ NAME = "newsSearch" SERVICE = "NewsSearchService" _RESULT_FACTORY = yahoo.search.dom.news.NewsSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(NewsSearch, self)._init_valid_params() self._valid_params.update({ "type" : (types.StringTypes, "any", str.lower, ("all", "any", "phrase"), None, False), "sort" : (types.StringTypes, "rank", str.lower, ("date", "rank"), None, False), "language" : (types.StringTypes, "en", str.lower, self.languages.keys(), None, False), "site" : (types.StringTypes, [], None, None, "a list of up to 30 domains", False), }) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/parser.py0000644001174600001440000001270610327763733016252 0ustar leifusers"""Base class for search results parsing This package implements the interface and base class that should be used for all parsers of the web results. It is used by the DOM parsers that we provide as defaults. """ __revision__ = "$Id: parser.py,v 1.4 2005/10/26 20:32:27 zwoop Exp $" __version__ = "$Revision: 1.4 $" __author__ = "Leif Hedstrom " __date__ = "Wed Oct 26 11:24:50 PDT 2005" # # Exceptions and error handling # class Error(Exception): """Base class for all Yahoo DOM Parser exceptions.""" class ClassError(Error): """This can only occur if the APIs aren't installed or configured properly. If it happens, please contact the author.""" class XMLError(Error): """This exception can occur if, and only if, Yahoo returns malformed XML results.""" # # Data conversion utilities # def string_to_bool(string): """Convert a string to a boolean value""" string = string.lower() if string == "false": return False elif string == "true": return True else: return bool(string) # # Simple wrapper around a dict, to present the dict keys # as "properties" # class ResultDict(dict): """ResultDict - Simple class to wrap the results """ def __getattr__(self, key): try: return self[key] except KeyError: raise AttributeError("Result object has no attribute '%s'" % key) # # Yahoo Search Web Services result classes/parsers (e.g. DOM) # class ResultParser(object): """Yahoo Search Web Service Results - base class This is the base class for all Yahoo Search Web Service result parsers. If you build your own result parser (e.g. non-DOM based), please sub- class ResultParser. The following attributes are always available: total_results_available total_results_returned first_result_position results Results are a list of dictionaries, which can be a custom class as required. An interator generator is provided for easy access to the list of results. For example, to iterate over all results, you would do something like: dom = ws.get_results() results = ws.parse_results(dom) dom.unlink() for res in results: print res['Url'] print res.Summary As you can see, each result is a customizable dictionary. The default results dict supports accessing each key as a "property", like the above example (res.Summary). You can also get the list of results directly, using the results attribute. An optional res_dict argument can be used to provide an alternative dictionary implementation to use for the results. """ def __init__(self, service, res_dict=ResultDict): self._service = service self._total_results_available = 0 self._total_results_returned = 0 self._first_result_position = 0 self._results = [] self._res_dict = res_dict self._res_fields = [] self._init_res_fields() def __iter__(self): return iter(self._results) def _init_res_fields(self): """Initialize the valid result fields.""" self._res_fields = [('Title', None, None), ('Summary', None, None), ('Url', None, None), ('ClickUrl', None, None)] def _get_results(self): """Get the results.""" return self._results results = property(_get_results, None, None, "The list of all results") def _get_service(self): """Get the service for this DOM parser.""" return self._service def _set_service(self, service): """Set the service for this DOM parser.""" self._service = service service = property(_get_service, _set_service, None, "The Search Web Service object for this results parser") def parse_results(self, result_set): """Parse the results.""" err = "Search Result class %s must implement a parse_result()" % ( self._service.svc_name) raise ClassError(err) def _get_total_results_available(self): """Get the total number of results for the query.""" return self._total_results_available total_results_available = property(_get_total_results_available, None, None, "Total number of results for the query") totalResultsAvailable = property(_get_total_results_available, None, None, "Total number of results for the query") def _get_total_results_returned(self): """Get the number of results returned.""" return self._total_results_returned total_results_returned = property(_get_total_results_returned, None, None, "The number of results returned") totalResultsReturned = property(_get_total_results_returned, None, None, "The number of results returned") def _get_first_result_position(self): """Get the first result position.""" return self._first_result_position first_result_position = property(_get_first_result_position, None, None, "The first result position") firstResultPosition = property(_get_first_result_position, None, None, "The first result position") # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/site.py0000644001174600001440000001540110571210411015672 0ustar leifusers"""yahoo.search.site - Site Explorer services module This module implements the Site Explorer web services, which can be used gain a unique perspective on your online presence. The supported classes of site explorer are: PageData - Shows a list of all pages belonging to a domain InlinkData - Shows the pages from other sites linking in to a page Update Notification - Notify Yahoo! of changes to your site An application ID (appid) is always required when instantiating a search object. In addition, each search class takes different set of parameters, as defined by this table PageData InlinkData Update Notification -------- ---------- ------------------- query [X] [X] . results [X] [X] . start [X] [X] . domain_only [X] . . entire_site . [X] . omit_inlinks . [X] . url . . [X] output [X] [X] . callback [X] [X] . Each of these parameter is implemented as an attribute of each respective class. For example, you can set parameters like: from yahoo.search.site import PageData srch = PageData(appid="YahooDemo") srch.query = "http://www.ogre.com" srch.results = 75 for res in srch.parse_results(): print res.Url """ import types import yahoo.search import yahoo.search.dom.site __revision__ = "$Id: site.py,v 1.3 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.3 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 21:54:42 MST 2007" # # PageData class # class PageData(yahoo.search._BasicSearch): """PageData - discover what is in the Yahoo! index This class implements the Page Data web service APIs. Allowed parameters are: query - The query to search for (UTF-8 encoded). results - The number of results to return (1-100). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. domain_only - Specifies whether to provide results for all subdomains (such as http://search.yahoo.com for http://www.yahoo.com) of the domain query, or just the specifically requested domain. If the query is not a domain URL (i.e. it contains path information, such as http://smallbusiness.yahoo.com/webhosting/), this parameter has no effect. Allowed values are 0 (default) or 1. output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around Full documentation for this service is available at: http://developer.yahoo.net/search/siteexplorer/V1/pageData.html """ NAME = "pageData" SERVICE = "SiteExplorerService" _RESULT_FACTORY = yahoo.search.dom.site.PageData def _init_valid_params(self): """Initialize the set of valid parameters.""" super(PageData, self)._init_valid_params() self._valid_params.update({ "results" : (types.IntType, 50, int, lambda x: x > -1 and x < 101, "the range 1 to 100", False), "domain_only" : (types.IntType, 0, int, (0, 1), None, False), }) # # InlinkData class # class InlinkData(yahoo.search._BasicSearch): """InlinkData - discover what pages link to your website This class implements the Inlink Data web service APIs. Allowed parameters are: query - The query to search for (UTF-8 encoded). results - The number of results to return (1-100). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. entire_site - Specifies whether to provide results for the entire site, or just the page referenced by the query. If the query is not a domain URL (i.e. it contains a path, such as http://smallbusiness.yahoo.com/webhosting/), this parameter has no effect. Allowed values are 0 (default) or 1. omit_inlinks - If specified, inlinks will not be returned if they are from pages in the same domain/subdomain as the requested page. Allowed values are domain or subdomain. output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around Full documentation for this service is available at: http://developer.yahoo.net/search/siteexplorer/V1/inlinkData.html """ NAME = "inlinkData" SERVICE = "SiteExplorerService" _RESULT_FACTORY = yahoo.search.dom.site.PageData def _init_valid_params(self): """Initialize the set of valid parameters.""" super(InlinkData, self)._init_valid_params() self._valid_params.update({ "results" : (types.IntType, 50, int, lambda x: x > -1 and x < 101, "the range 1 to 100", False), "entire_site" : (types.IntType, 0, int, (0, 1), None, False), "omit_inlinks" : (types.StringTypes, None, str.lower, ("domain", "subdomain"), None, False), }) # # UpdateNotification class # class UpdateNotification(yahoo.search._Search): """UpdateNotification - Tell the Yahoo! to index your URLs This class implements the Update Notification web service APIs. Allowed parameters are: url - The URL to submit Full documentation for this service is available at: http://developer.yahoo.com/search/siteexplorer/V1/updateNotification.html """ NAME = "updateNotification" SERVICE = "SiteExplorerService" _RESULT_FACTORY = yahoo.search.dom.site.UpdateNotification def _init_valid_params(self): """Initialize the set of valid parameters.""" self._valid_params = ({ "url" : (types.StringTypes, None, None, None, None, True), }) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/term.py0000644001174600001440000000462610571210411015704 0ustar leifusers"""yahoo.search.term - Term Extraction web services module This module implements the the Term Extraction web service, to extract significant words and phrases from a larger context. There is currently only one class implemented, TermExtraction. An application ID (appid) is always required when instantiating a search object. Additional parameters are documented in the TermExtraction class. Example: from yahoo.search.term import TermExtraction srch = TermExtraction(app_id="YahooDemo", query="Yahoo") srch.context = "portal news sports mail messenger" for res in srch.parse_results(): print res """ import types import yahoo.search import yahoo.search.dom.term __revision__ = "$Id: term.py,v 1.5 2007/02/28 05:20:09 zwoop Exp $" __version__ = "$Revision: 1.5 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 14:26:00 MST 2007" # # VideoSearch class # class TermExtraction(yahoo.search._Search): """TermExtraction - Extract words or phrases from a larger content This class implements the Web Search Spelling Suggestion web service APIs. The only allowed parameter is: context - The context to extract terms from (UTF-8 encoded) query - An optional query to help with the extraction process output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. The Term Extraction service provides a list of significant words or phrases extracted from a larger content. It is one of the technologies used in Y!Q. Full documentation for this service is available at: http://developer.yahoo.net/content/V1/termExtraction.html """ NAME = "termExtraction" SERVICE = "ContentAnalysisService" METHOD = "POST" _RESULT_FACTORY = yahoo.search.dom.term.TermExtraction def _init_valid_params(self): """Initialize the set of valid parameters.""" self._valid_params.update({ "query" : (types.StringTypes, None, None, None, None, False), "context" : (types.StringTypes, None, None, None, None, True), }) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/version.py0000644001174600001440000000111310671606574016432 0ustar leifusers""" yahoo.search.version - Version information """ version = "3.1" authorName = "Leif Hedstrom" authorMail = "leif@ogre.com" maintainerName = "Leif Hedstrom" maintainerMail = "leif@ogre.com" credits = """- The entire Yahoo search team, of course. """ author = "%s <%s>" % (authorName, authorMail) __revision__ = "$Id: version.py,v 1.13 2007/09/11 21:49:48 zwoop Exp $" __version__ = "$Revision: 1.13 $" __author__ = "Leif Hedstrom " __date__ = "Tue Sep 11 15:49:27 MDT 2007" # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/video.py0000644001174600001440000000671510571210413016046 0ustar leifusers"""yahoo.search.video - Video Search services module This module implements the the Video Search web service, to do search queries on various video formats. There is currently only one class implemented, VideoSearch. An application ID (appid) is always required when instantiating a search object. Additional parameters are documented in the VideoSearch class. Example: from yahoo.search.video import VideoSearch srch = VideoSearch(app_id="YahooDemo", query="Yahoo", results=10) for res in srch.parse_results(): print res.Title """ import types import yahoo.search import yahoo.search.dom.video __revision__ = "$Id: video.py,v 1.6 2007/02/28 05:20:11 zwoop Exp $" __version__ = "$Revision: 1.6 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 21:13:43 MST 2007" # # VideoSearch class # class VideoSearch(yahoo.search._CommonSearch): """VideoSearch - perform a Yahoo Video Search This class implements the Video Search web service APIs. Allowed parameters are: query - The query to search for (UTF-8 encoded). type - The kind of search to submit: * "all" returns results with all query terms. * "any" resturns results with one or more of the query terms. * "phrase" returns results containing the query terms as a phrase. results - The number of results to return (1-50). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. format - Specifies the kind of video file to search for. adult_ok - The service filters out adult content by default. Enter a 1 to allow adult content. site - A domain to restrict your searches to (e.g. www.yahoo.com). You may submit up to 30 values (e.g. ["www.yahoo.com", "www.cnn.com"]). output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Supported formats are any - Match all formats avi - AVI flash - Flash mpeg - MPEG msmedia - Microsoft Media quicktime - Apple Quicktime realmedia - Realmedia Full documentation for this service is available at: http://developer.yahoo.net/video/V1/videoSearch.html """ NAME = "videoSearch" SERVICE = "VideoSearchService" _RESULT_FACTORY = yahoo.search.dom.video.VideoSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(VideoSearch, self)._init_valid_params() self._valid_params.update({ "format" : (types.StringTypes, "any", str.lower, ("all", "all", "avi", "flash", "mpeg", "msmedia", "quicktime", "realmedia"), None, False), "site" : (types.StringTypes, [], None, None, "a list of up to 30 domains", False), }) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/web.py0000644001174600001440000003042310571210413015506 0ustar leifusers"""yahoo.search.web - Web Search services module This module implements the Web Search web services, searching web content. The supported classes of web searches are: WebSearch - Web Search ContextSearch - Web Search with a context added RelatedSuggestion - Web Search Related Suggestion SpellingSuggestion - Web Search Spelling Suggestion An application ID (appid) is always required when instantiating a search object. In addition, each search class takes different set of parameters, as defined by this table Web Context Related Spelling ----- ------- ------- -------- query [X] [X] [X] [X] region [X] . . . context . [X] . . type [X] [X] . . results [X] [X] [X] . start [X] [X] . . format [X] [X] . . adult_ok [X] [X] . . similar_ok [X] [X] . . language [X] [X] . . country [X] [X] . . site [X] . . . subscription [X] . . . output [X] [X] [X] [X] callback [X] [X] [X] [X] Each of these parameter is implemented as an attribute of each respective class. For example, you can set parameters like: from yahoo.search.web import WebSearch srch = WebSearch(app_id="YahooDemo") srch.query = "Leif Hedstrom" srch.results = 40 for res in srch.parse_results(): print res.Url """ import types import yahoo.search import yahoo.search.dom.web __revision__ = "$Id: web.py,v 1.10 2007/02/28 05:20:11 zwoop Exp $" __version__ = "$Revision: 1.10 $" __author__ = "Leif Hedstrom " __date__ = "Sun Feb 25 21:47:52 MST 2007" # # WebSearch class # class WebSearch(yahoo.search._CommonSearch): """WebSearch - perform a Yahoo Web Search This class implements the Web Search web service APIs. Allowed parameters are: query - The query to search for (UTF-8 encoded). region - The regional search engine on which the service performs the search. For example, region=uk will give you the search engine at uk.search.yahoo.com. type - The kind of search to submit (all, any or phrase) * all returns results with all query terms. * any resturns results with one or more of the query terms. * phrase returns results containing the query terms as a phrase. results - The number of results to return (1-100). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. format - Specifies the kind of web file to search for. adult_ok - The service filters out adult content by default. Enter a 1 to allow adult content. similar_ok - Specifies whether to allow multiple results with similar content. Enter a 1 to allow similar content language - The language the results are written in. country - The country code for the country the website is located in. site - A domain to restrict your searches to (e.g. www.yahoo.com). You may submit up to 30 values (e.g. ["www.yahoo.com", "www.cnn.com"]). subscription - Any subscriptions to premium content that should also be searched. You may submit multiple values. license - The Creative Commons license that the contents are licensed under. You may submit multiple values (e.g. [cc_commercial, cc_modifiable] ). output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Supported values for 'format' are html - Regular HTML / XHTML msword - Microsoft Word pdf - Adobe PDF ppt - Microsoft PowerPoint rss - RSS feed txt - Text file xls - Microsft Excel Full documentation for this service is available at: http://developer.yahoo.net/web/V1/webSearch.html """ NAME = "webSearch" SERVICE = "WebSearchService" _RESULT_FACTORY = yahoo.search.dom.web.WebSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(WebSearch, self)._init_valid_params() self._valid_params.update({ "region" : (types.StringTypes, "us", str.lower, self.regions.keys(), None, False), "results" : (types.IntType, 10, int, lambda x: x > -1 and x < 101, "the range 1 to 100", False), "format" : (types.StringTypes, "any", str.lower, ("all", "any", "html", "msword", "pdf", "ppt", "rss", "txt", "xls"), None, False), "similar_ok" : (types.IntType, None, int, (1,), None, False), "language" : (types.StringTypes, "en", str.lower, self.languages.keys(), None, False), "country" : (types.StringTypes, "default", str.lower, self.countries.keys(), None, False), "site" : (types.StringTypes, [], None, None, "a list of up to 30 domains", False), "subscription" : (types.StringTypes, [], str.lower, self.subscriptions.keys(), None, False), "license" : (types.StringTypes, [], str.lower, self.cc_licenses.keys(), None, False), }) # # ContextSearch class, very similar to WebSearch # class ContextSearch(yahoo.search._CommonSearch): """ContextSearch - perform a Yahoo Web Search with a context This class implements the Contextual Web Search service APIs, which is very similar to a regular web search. Allowed parameters are: query - The query to search for (UTF-8 encoded). context - The context to extract meaning from (UTF-8 encoded). type - The kind of search to submit (all, any or phrase). * all returns results with all query terms. * any resturns results with one or more of the query terms. * phrase returnes results containing the query terms as a phrase. results - The number of results to return (1-100). start - The starting result position to return (1-based). The finishing position (start + results - 1) cannot exceed 1000. format - Specifies the kind of web file to search for. adult_ok - The service filters out adult content by default. Enter a 1 to allow adult content. similar_ok - Specifies whether to allow multiple results with similar content. Enter a 1 to allow similar content. language - The language the results are written in. country - The country code for the country the website is located in. license - The Creative Commons license that the contents are licensed under. You may submit multiple values (e.g. license=cc_commercial&license=cc_modifiable). output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Supported formats are html - Regular HTML / XHTML msword - Microsoft Word pdf - Adobe PDF ppt - Microsoft PowerPoint rss - RSS feed txt - Text file xls - Microsft Excel Full documentation for this service is available at: http://developer.yahoo.net/web/V1/contextSearch.html """ NAME = "contextSearch" SERVICE = "WebSearchService" METHOD = "POST" _RESULT_FACTORY = yahoo.search.dom.web.WebSearch def _init_valid_params(self): """Initialize the set of valid parameters.""" super(ContextSearch, self)._init_valid_params() self._valid_params.update({ "results" : (types.IntType, 10, int, lambda x: x > -1 and x < 101, "the range 1 to 100", False), "context" : (types.StringTypes, None, None, None, None, True), "format" : (types.StringTypes, "any", str.lower, ("all", "any", "html", "msword", "pdf", "ppt", "rss", "txt", "xls"), None, False), "similar_ok" : (types.IntType, None, int, (1,), None, False), "language" : (types.StringTypes, "en", str.lower, self.languages.keys(), None, False), "country" : (types.StringTypes, "default", str.lower, self.countries.keys(), None, False), "license" : (types.StringTypes, [], str.lower, self.cc_licenses.keys(), None, False), }) # # RelatedSuggestion class # class RelatedSuggestion(yahoo.search._Search): """RelatedSuggestion - perform a Yahoo Web Related Suggestions search This class implements the Web Search Related Suggestion web service APIs. The only allowed parameters are: query - The query to get related searches from results - The number of results to return (1-50) output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Full documentation for this service is available at: http://developer.yahoo.net/web/V1/relatedSuggestion.html """ NAME = "relatedSuggestion" SERVICE = "WebSearchService" _RESULT_FACTORY = yahoo.search.dom.web.RelatedSuggestion def _init_valid_params(self): """Initialize the set of valid parameters.""" self._valid_params.update({ "query" : (types.StringTypes, None, None, None, None, True), "results" : (types.IntType, 10, int, lambda x: x > -1 and x < 51, "the range 1 to 50", False), }) # # SpellingSuggestion class # class SpellingSuggestion(yahoo.search._Search): """SpellingSuggestion - perform a Yahoo Web Spelling Suggestion search This class implements the Web Search Spelling Suggestion web service APIs. The only allowed parameter is: query - The query to get spelling suggestions for output - The format for the output result. If json or php is requested, the result is not XML parseable, so we will simply return the "raw" string. callback - The name of the callback function to wrap around the JSON data. Full documentation for this service is available at: http://developer.yahoo.net/web/V1/spellingSuggestion.html """ NAME = "spellingSuggestion" SERVICE = "WebSearchService" _RESULT_FACTORY = yahoo.search.dom.web.SpellingSuggestion def _init_valid_params(self): """Initialize the set of valid parameters.""" self._valid_params.update({ "query" : (types.StringTypes, None, None, None, None, True), }) # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/search/webservices.py0000755001174600001440000001710310671605343017270 0ustar leifusers"""Yahoo Search Web Services --- NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE --- This module is deprecated, please see the documentation for yahoo.search and use the new class structures. The old DOM parser is also obsolote, and not distributed with this package at all. For documentation on the results produced by the various search classes, please refer to the appropriate DOM parser docs. --- NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE --- This module implements a set of classes and functions to work with the Yahoo Search Web Services. All results from these services are properly formatted XML, and this package facilitates for proper parsing of these result sets. Some of the features include: * Extendandable API, with replaceable backend XML parsers, and I/O interface. * Type and value checking on search parameters, including automatic type conversion (when appropriate and possible) * Flexible return format, including DOM objects, or fully parsed result objects You can either instantiate a search object directly, or use the factory function create_search() in this module (see below). The supported classes of searches are: VideoSearch - Video Search ImageSearch - Image Search WebSearch - Web Search NewsSearch - News Search LocalSearch - Local Search RelatedSuggestion - Web Search Related Suggestion SpellingSuggestion - Web Search Spelling Suggestion TermExtraction - Term Extraction service ContextSearch - Web Search with a context The different sub-classes of Search supports different sets of query parameters. They all require an application ID parameter (app_id). The following tables describes all other allowed parameters for each of the supported services: Web Related Spelling Context Term ----- ------- -------- ------- ------ query [X] [X] [X] [X] [X] type [X] . . [X] . results [X] [X] . [X] . start [X] . . [X] . format [X] . . . . adult_ok [X] . . [X] . similar_ok [X] . . [X] . language [X] . . . . country [X] . . . . context . . . [X] [X] Image Video News Local ----- ----- ----- ----- query [X] [X] [X] [X] type [X] [X] [X] . results [X] [X] [X] [X] start [X] [X] [X] [X] format [X] [X] . . adult_ok [X] [X] . . language . . . [X] country . . . . sort . . [X] [X] coloration [X] . . . radius . . . [X] street . . . [X] city . . . [X] state . . . [X] zip . . . [X] location . . . [X] longitude . . . [X] latitude . . . [X] Each of these parameter is implemented as an attribute of each respective class. For example, you can set parameters like: from yahoo.search.webservices import WebSearch app_id = "YahooDemo" srch = WebSearch(app_id) srch.query = "Leif Hedstrom" srch.results = 40 or, if you are using the factory function: from yahoo.search.webservices import create_search app_id = "YahooDemo" srch = create_search("Web", app_id, query="Leif Hedstrom", results=40) or, the last alternative, a combination of the previous two: from yahoo.search.webservices import WebSearch app_id = "YahooDemo" srch = WebSearch(app_id, query="Leif Hedstrom", results=40) To retrieve a certain parameter value, simply access it as any normal attribute: print "Searched for ", srch.query For more information on these parameters, and their allowed values, please see the official Yahoo Search Services documentation available at http://developer.yahoo.net/ Once the webservice object has been created, you can retrieve a parsed object (typically a DOM object) using the get_results() method: dom = srch.get_results() This DOM object contains all results, and can be used as is. For easier use of the results, you can use the built-in results factory, which will traverse the entire DOM object, and create a list of results objects. results = srch.parse_results(dom) or, by using the implicit call to get_results(): results = srch.parse_results() The default XML parser and results factories should be adequate for most users, so use the parse_results() when possible. However, both the XML parser and the results parser can easily be overriden. See the examples below for details. EXAMPLES: This simple application will create a search object using the first command line argument as the "type" (e.g. "web" or "news"), and all subsequent arguments forms the query string: #!/usr/bin/python import sys from yahoo.search.webservices import create_search service = sys.argv[1] query = " ".join(sys.argv[2:]) app_id = "YahooDemo" srch = create_search(service, app_id, query=query, results=5) if srch is None: srch = create_search("Web", app_id, query=query, results=5) dom = srch.get_results() results = srch.parse_results(dom) for res in results: url = res.Url summary = res['Summary'] print "%s -> %s" (summary, url) The same example using the PyXML 4DOM parser: #!/usr/bin/python import sys from yahoo.search.webservices import create_search from xml.dom.ext.reader import Sax2 query = " ".join(sys.argv[2:]) srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5) if srch is not None: reader = Sax2.Reader() srch.install_xml_parser(reader.fromStream) . . . The last example will produce the same query, but uses an HTTP proxy for the request: #!/usr/bin/python import sys from yahoo.search.webservices import create_search import urllib2 query = " ".join(sys.argv[2:]) srch = create_search(sys.argv[1], "YahooDemo", query=query, results=5) if srch is not None: proxy = urllib2.ProxyHandler({"http" : "http://octopus:3128"}) opener = urllib2.build_opener(proxy) srch.install_opener(opener) . . . You can obviously "mix and match" as necessary here. I'm using the installer methods above for clarity, the APIs allows you to pass those custom handlers as arguments as well (see the documentation below). """ # # Merge the new namespace into this obsolote namespace. # from yahoo.search.web import * from yahoo.search.news import * from yahoo.search.video import * from yahoo.search.image import * from yahoo.search.local import * from yahoo.search.term import * from yahoo.search import LANGUAGES from yahoo.search import COUNTRIES from yahoo.search import CC_LICENSES from yahoo.search import SUBSCRIPTIONS from yahoo.search.factory import SERVICES from yahoo.search.factory import create_search __revision__ = "$Id: webservices.py,v 1.32 2007/09/11 21:38:43 zwoop Exp $" __version__ = "$Revision: 1.32 $" __author__ = "Leif Hedstrom " __date__ = "Tue Sep 11 15:37:37 MDT 2007" # # local variables: # mode: python # indent-tabs-mode: nil # py-indent-offset: 4 # end: pYsearch-3.1/yahoo/__init__.py0000644001174600001440000000000010177270051015215 0ustar leifuserspYsearch-3.1/ChangeLog0000644001174600001440000002272010671606605013563 0ustar leifusers2007-09-11 Leif Hedstrom * version.py (version): Bump version. * __init__.py: Removed AppID, and all MyWeb support. * webservices.py: Removed AppID. 2007-02-27 Leif Hedstrom * site.py (UpdateNotification): New class, to send URLs for indexing. * myweb.py: Support for output and callback. * local.py: Updated with all V3 features, and support for output and callback. 2007-02-25 Leif Hedstrom * image.py: Support output and callback. * term.py: Support output and callback. * local.py: Fixed the server and version, updated for V3. * audio.py: All search classes now support output and callback parameters. * audio.py: Cleanup the documentation a bit. * __init__.py: New server for Yahoo Search APIs, search.yahooapis.com. * __init__.py (_Search): Make it implicitly inherit from "object", to make pylint happier. 2006-10-12 Leif Hedstrom * site.py (InlinkData): Added new parameter, omit_inlinks, as well as support for output and callback. (PageData): Added support for output and callback. * video.py (VideoSearch): Added support for output and callback. * __init__.py (_Search.__init__): Added output and callback to the default valid_params. Also save the default XML parser. (_Search.__setattr__): Add a special case for "output", since we need to change the xml_parser for JSON and PHP. * web.py (WebSearch): Support for output and callback. Added XLS as a supported format. (ContextSearch): Dito. (RelatedSuggestion): Support for output and callback. (SpellingSuggestion: Dito. * __init__.py (_Search.get_results): Added support for returning raw XML (or JSON or PHP). This was both buggy and unfinished. (_Search.open): Added a feature to allow us to retry certain HTTP failures. This seems to help intermittent Yahoo problems. 2006-08-21 Leif Hedstrom * term.py (TermExtraction): Make query parameter optional for TermExtraction. 2005-12-06 Leif Hedstrom * __init__.py (REGIONS): Added the regions mappings, for new region option. 2005-11-13 Leif Hedstrom * Lots of doc changes, fixed example bugs, modified all examples to use YahooDemo as appid. 2005-10-27 Leif Hedstrom * __init__.py: Removed the require_oneof_param attribute. * Release v2.0 (CVS tag: release_2_0) * site.py: New module, implementing site explorer APIs. * audio.py (SongDownloadLocation): Added support for SongDownloadLocation. 2005-10-26 Leif Hedstrom * audio.py (AlbumSearch): Added support for AlbumSearch. (SongSearch): Added support for SongSearch. (PodcastSearch): Added support for PodcastSearch. * __init__.py (_Search): Implement a "require_oneof_params" list, which lets us assure that at least one of a list of parameters are provided. * factory.py: Added support for ArtistSearch. 2005-10-25 Leif Hedstrom * audio.py (ArtistSearch): New Audio search class, to search for artists. 2005-10-18 Leif Hedstrom * myweb.py (RelatedTags): New MyWeb2 class. 2005-10-17 Leif Hedstrom * myweb.py (UrlSearch): New MyWeb2 class, search for URLs by tag. (TagSearch): Dito. 2005-10-15 Leif Hedstrom * local.py: Refactored. * image.py: Refactored. * web.py): Added support for the site parameters. (ContextSearch): Added missing parameters. * news.py: Added support for the site parameters. 2005-06-30 Leif Hedstrom * webservices.py (ListUrls): Added sort and sort_order parameters. 2005-06-22 Leif Hedstrom * webservices.py (ContextSearch): Cleanup of valid parameters supported for ContextSearch. 2005-06-21 Leif Hedstrom * webservices.py (WebSearch): Added support for the subscription parameter. 2005-04-30 Leif Hedstrom * domparsers.py: Cleaned up a lot of code to make pychecker and pylint happier. * webservices.py: Cleaned up a lot of code, to make pychecker and pylint happier. Removed all the stupid "Params" classes, no more ugly multiple- inheritance. Move all the Unit tests to it's own test module. 2005-04-29 Leif Hedstrom * webservices.py: Added missing documentation, doh! Documented how to use alternative DOM parsers, and an HTTP proxy. (_Search.open): Bug fix: We did not properly support the URL opener as set in the CTOR or by the installer method. (_Search.missing_params): New method to validate that all required parameters are properly set. (_Search._init_valid_params): Documented the syntax, and added another item to indicate if a parameter is required or not. (_Search.set_param): Properly support the specific help text for parameters that define such a string. 2005-04-28 Leif Hedstrom * webservices.py (ListFolders): New class for List Folders. (ListUrls): New class for List Urls. Added Unit tests for these two new classes. Released v1.3. * domparsers.py (ListFolders): New class to support the List Folders service. (ListUrls): New class to support the List Urls service. * webservices.py: Removed all service specific attributes. (_Search.__setattr__): Implement all the parameter checking etc. through the valid_params here. This also solves the problem where you could accidentally set an invalid parameter for a particular search object. (_Search.__getattr__): Get the parameters properly. 2005-04-27 Leif Hedstrom * webservices.py: Minor cleanups. 2005-03-31 Leif Hedstrom * webservices.py (TermExtraction): New search feature. Release 1.2. 2005-03-29 Leif Hedstrom * webservices.py (_Search.get_results): Added debug output for pretty printed XML. Fixed some of the Unit tests to be more robusts. * debug.py (Debuggable.debug_msg): Try to handle Unicode strings. 2005-03-24 Leif Hedstrom * webservices.py: Changed the defaults from "all" to "any". (WebSearch._set_license): New property, for CC license filter. (CC_LICENSES): New constant, holding valid CC license strings. (WebSearch): Added support for CC license. (_Search.set_param): Added support for parameters of list values. (_BasicParams._init_valid_params): Added range check on start (ContextSearch): New class, based on WebSearch, to do contextual web searches. (_Search.get_url): Make parameter encoding separate and optional. (_Search.encode_params): Separated out from get_url(). 2005-03-14 Leif Hedstrom * webservices.py: Basic Unit test framework. * debug.py (Debuggable._debug_msg): Changed the message to look more debugging like ... * webservices.py (LANGUAGES): Turned it in to a dictionary, holding the name of the language as well as the ISO code. (COUNTRIES): New dictionary, for countery parameter (in web search) (WebSearch._init_valid_params): Added support for the new country parameter. 2005-03-11 Leif Hedstrom * webservices.py (_Search.set_param): Support verifying parameter values using a lambda expression as well as tuples/lists. (LocalSearch._init_valid_params): Added support for the sort parameter. 2005-03-09 Leif Hedstrom * webservices.py (LocalSearch._init_valid_params): Added support for longitude and latitude. 2005-02-18 Leif Hedstrom * domparsers.py (AudioSearch): Cleaned up Duration parsing. (VideoSearch): Ditto. (AudioSearch._init_res_fields): Fixed Channels to be decimal. (VideoSearch._init_res_fields): Ditto. (LocalSearch.parse_results): Added support for ResultSetMapUrl. * webservices.py (LANGUAGES): Changed to be public. (ERROR): Changed to be public. (_Search.__init__): Changed the documentation for app_id. (_Search._init_valid_params): Made a pure virtual function, to avoid class errors. (_Search._set_app_id): Changed to use the module global for the regex. (APPID_REGEX): Moved the regex out to be a module global, to possibly allow for it to be modified (to be more strict for instance). (_Search.set_param): Added check for None values (not allowed) (_Search.set_param): The error message on invalid value used wrong pinfo. (_Search.open): Slightly better error handling. (all search classes): Changed the inheritance order to prioritize the parameters base class(es). (_CommonParams._set_format): Fixed, used the wrong setters/getters. * domparsers.py (string_to_bool): Changed parameter name from 'str' to 'string', to avoid unecessary overloading warnings. (SearchParser.parse_results): Bug fix, use self._service.svc_name to get to the service name. 2005-02-16 Leif Hedstrom * webservices.py (_Search._set_app_id): Check the app_id against a regex. 2005-02-15 Leif Hedstrom * webservices.py (_Search._set_app_id): Added support for the new Application ID parameter (required). 2005-02-09 Leif Hedstrom * webservices.py: Fixed all the range() to include the max number as well. * domparsers.py (SearchParser): Fixed all the getters for results counters. * webservices.py (NewsSearch._init_valid_params): Fixed the sort argument to use "rank" or "date". 2005-02-08 Leif Hedstrom * domparsers.py (LocalSearch._parse_result): Fixed "unit". 2005-02-02 Leif Hedstrom * webservices.py (AudioSearch._init_valid_params): Removed "streamed". * domparsers.py (SearchDOMParser._tags_to_dict): Changed format, to provide both a "normalizer" and a default value. We'll raise an exception here on missing XML data. pYsearch-3.1/Makefile0000644001174600001440000000424510330213577013445 0ustar leifusers# # $Id: Makefile,v 1.12 2005/10/27 18:07:59 zwoop Exp $ # # Simple Makefile to build packages, run tests, generate docs etc. # Not very advanced, but it does the job for now ... # # # Building, packaging and registration # .PHONY : build install dist register clean build: python setup.py build install: python setup.py install dist: cp yahoo/search/ChangeLog ChangeLog python setup.py sdist --formats=gztar rm ChangeLog register: python setup.py register clean: rm -rf dist build # # Tests and docs # VPATH = yahoo/search:yahoo/search/dom PYTHONPATH = .. docs/yahoo.search.dom.%.html : dom/%.py yahoo/search/dom/__init__.py pydoc -w yahoo.search.dom.`basename $< .py` mv `basename $@` $@ docs/yahoo.search.%.html : %.py yahoo/search/__init__.py pydoc -w yahoo.search.`basename $< .py` mv `basename $@` $@ .PHONY : test docs test: @cd test && gmake pylint: @pylint --rcfile=pylint.rc yahoo/search/*.py yahoo/search/dom/*.py docs: docs/yahoo.search.html \ docs/yahoo.search.web.html \ docs/yahoo.search.news.html \ docs/yahoo.search.image.html \ docs/yahoo.search.video.html \ docs/yahoo.search.local.html \ docs/yahoo.search.term.html \ docs/yahoo.search.myweb.html \ docs/yahoo.search.audio.html \ docs/yahoo.search.site.html \ docs/yahoo.search.parser.html \ docs/yahoo.search.factory.html \ docs/yahoo.search.debug.html \ docs/yahoo.search.version.html \ docs/yahoo.search.webservices.html \ docs/yahoo.search.dom.html \ docs/yahoo.search.dom.web.html \ docs/yahoo.search.dom.news.html \ docs/yahoo.search.dom.image.html \ docs/yahoo.search.dom.video.html \ docs/yahoo.search.dom.local.html \ docs/yahoo.search.dom.term.html \ docs/yahoo.search.dom.myweb.html \ docs/yahoo.search.dom.audio.html \ docs/yahoo.search.dom.site.html \ docs/index.html \ docs/yahoo.html docs/yahoo.search.html: yahoo/search/__init__.py pydoc -w yahoo.search mv `basename $@` $@ docs/yahoo.search.dom.html: yahoo/search/dom/__init__.py pydoc -w yahoo.search.dom mv `basename $@` $@ docs/yahoo.html: yahoo/__init__.py pydoc -w yahoo mv `basename $@` $@ docs/index.html: docs/yahoo.search.html cp $< $@ push: rsync -az -e ssh docs/ shell.sf.net:pysearch/htdocs/docs pYsearch-3.1/NEWS0000644001174600001440000000276110671605107012507 0ustar leifusers[09/11/07] pYsearch v3.1 ------------------------ * Removed checks for appID format. * Removed all MyWeb v1 and v2 features. [02/27/07] pYsearch v3.0 ------------------------ * Added support for region parameter in Web search. * Updates to documentation (missing new services). * Added support for PHP and JSON responses. * Updated all web services with latest parameters. * Updated to support all Search services. [10/27/05] pYsearch v2.0 ------------------------ * Added support for MyWeb2, Audio and Site Explorer. * Major refactoring of all classes/modules. * Updated with all changes to Search APIs, parameters etc. * Improved documentation and examples. * Plenty of bugfixes.... I mean, improvements. [4/28/05] pYsearch v1.3 ----------------------- * Added support for MyWeb List Folders and List URLs. * Improved parameter handling. [3/31/05] pYsearch v1.2 ----------------------- * Added support for Term extraction. * Added support for contextual searches. * Added support for Creative Commons license parameter. * Added some basic unit tests. * Modified debug levels slightly. [3/14/05] pYsearch v1.1 ----------------------- * Added support for new Local Search features: Long/lat and sort order. * Added support for new Web Search feature: County parameter. * Added support for new Image search feature: Coloration parameter. * LANGUAGE and COUNTRY "globals" are now dictionaries. [2/28/05] pYsearch v1.0 ----------------------- * First public release, moderately tested . pYsearch-3.1/README0000644001174600001440000000205310571065707012667 0ustar leifusersYahoo Search Web Services ========================= Created and maintained by Leif Hedstrom Copyright (C) 2006 Leif Hedstrom Copyright (C) 2005 Yahoo! Inc. Installation ------------ Installation is simple, assuming you have Python v2.2 or later, simply do: $ python setup.py build $ python setup.py install See the docs and examples for how to use it. We recently moved the development of pYsearch to be hosted by SourceForge, visit us at http://pysearch.sourceforge.net/ Bugs and missing features ------------------------- * Update the websearch "example" application with support for more search services and arguments. * HTTP error codes are somewhat sketchy. * I'd like to get this to work properly with both multi-threaded apps and asynchronous I/O frameworks. In particular, I need it to work with at least Medusa (async-core), and preferably with Twisted as well. * We have no way of validating that there is 30 or less site arguments. * Validate Yahoo IDs? * Validate URLs when passed as query arguments? pYsearch-3.1/setup.py0000644001174600001440000000314110571210617013510 0ustar leifusers#!/usr/bin/env python __revision__ = "$Id: setup.py,v 1.8 2007/02/28 05:22:23 zwoop Exp $" __version__ = "$Revision: 1.8 $" __author__ = "Leif Hedstrom " __date__ = "Tue Feb 27 22:21:49 MST 2007" from distutils.core import setup from yahoo.search import version setup(name="pYsearch", packages=['yahoo', 'yahoo.search', 'yahoo.search.dom'], version=version.version, description="Yahoo Search Web Services SDK for Python", author=version.authorName, author_email=version.authorMail, maintainer=version.maintainerName, maintainer_email=version.maintainerMail, url="http://pysearch.sourceforge.net/", download_url="http://prdownloads.sourceforge.net/pysearch/pYsearch-3.0.tar.gz?download", license="http://www.opensource.org/licenses/bsd-license.php", platforms=["any"], keywords=["yahoo", "search", "API", "web services"], long_description="""This module implements a set of classes and functions to work with the Yahoo Search Web Services. All results from these services are properly formatted XML, and this package facilitates for correct parsing of these result sets.""", classifiers=["Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "Operating System :: OS Independent", "License :: OSI Approved :: BSD License", "Topic :: Internet :: WWW/HTTP :: Indexing/Search", "Topic :: Software Development :: Libraries", ], ) pYsearch-3.1/PKG-INFO0000644001174600001440000000177210671606606013113 0ustar leifusersMetadata-Version: 1.0 Name: pYsearch Version: 3.1 Summary: Yahoo Search Web Services SDK for Python Home-page: http://pysearch.sourceforge.net/ Author: Leif Hedstrom Author-email: leif@ogre.com License: http://www.opensource.org/licenses/bsd-license.php Download-URL: http://prdownloads.sourceforge.net/pysearch/pYsearch-3.0.tar.gz?download Description: This module implements a set of classes and functions to work with the Yahoo Search Web Services. All results from these services are properly formatted XML, and this package facilitates for correct parsing of these result sets. Keywords: yahoo,search,API,web services Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: BSD License Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search Classifier: Topic :: Software Development :: Libraries