Module web_search
[show private | hide private]
[frames | no frames]

Module web_search

Query Web search engines.

This module works by filtering the HTML returned by the search engine and thus tends to break when search engines modify their HTML output.

Public domain, Connelly Barnes 2005-2007. Compatible with Python 2.3-2.5.

See examples for a quick start. See description for the full explanation, precautions, and legal disclaimers.
Function Summary
Full explanation and precautions for web_search module.
Examples of the web_search module.

Function Details


Full explanation and precautions for web_search module.

The search functions in this module follow a common interface:
   search(query, max_results=10, blocking=True) =>
     iterator of (name, url, description) search results.

Here query is the query string, max_results gives the maximum number of search results, and the items in the returned iterator are string 3-tuples containing the Website name, URL, and description for each search result.

If blocking=False, then an iterator is returned which does not block execution: the iterator yields None when the next search result is not yet available (a background thread is created).

Supported search engines are 'ask', 'dmoz', 'excite', 'google', 'msn', 'yahoo'. This module is not associated with or endorsed by any of these search engine corporations.

Be warned that if searches are made too frequently, or max_results is large and you enumerate all search results, then you will be a drain on the search engine's bandwidth, and the search engine organization may respond by banning your IP address or IP address range.

This software has been placed in the public domain with the following legal notice:


Examples of the web_search module.

Example 1:
>>> from web_search import google
>>> for (name, url, desc) in google('python', 20):
...   print name, url

(First 20 results for Google search of "python").
Example 2:
>>> from web_search import dmoz
>>> list(dmoz('abc', 10))
[('', '', "What's on ABC..."), ...]

Generated by Epydoc 2.1 on Sat Feb 3 16:45:05 2007