GithubHelp home page GithubHelp logo

jayvdb / opensearch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from edsu/opensearch

0.0 3.0 0.0 74 KB

A python opensearch client

Home Page: http://python.org/pypi/opensearch

Python 100.00%

opensearch's Introduction

opensearch

opensearch is a python library for talking to opensearch servers. Both v1.0 and v1.1 interactions are supported. You can find out more about opensearch at opensearch.org.

Usage

Here's the basic idea:

from opensearch import Client

client = Client(description_url)
results = client.search('zx81')

for result in results:
    print result.title, result.link

If you have a template with some non-standard query parameters like key in this template:

   <Url type="application/atom+xml" template="http://example.org/search?q={searchTerms}&amp;start={startIndex?}&amp;count={resultSize?}&amp;key={key}"/>

you can send the parameter like so:

results = client.search('zx81', key="abc123")

If the template happens to use a namespace prefix, as in this real example from the OCLC Worldcat API, which uses wcapi:wskey:

<Url type="application/atom+xml" xmlns:wcapi="http://www.worldcat.org/devnet/wiki/SearchAPIDetails" template="http://worldcat.org/webservices/catalog/search/worldcat/opensearch?q={searchTerms}&amp;start={startIndex?}&amp;count={resultSize?}&amp;format=atom&amp;wskey={wcapi:wskey}&amp;cformat={wcapi:cformat?}"/>

You can supply wcapi:wskey using the underscore notation:

results = client.search('zx81', wcapi__wskey="abc123")

Debugging

If you run into trouble and would like to see what URLs are being accessed behind the scenes, turn on logging and set the log level to DEBUG:

import logging
logging.basicConfig(level=logging.DEBUG)

To Do

  • handle v1.1 that want a POST instead of a GET
  • figure out if the latest feedparser can be used as a dependency
  • validate required parameters

License

The opensearch code itself has been released under the GPL.

One exception is that the distro bundles Mark Pilgrim's Universal Feed Parser, which is licensed separately under the MIT license. See opensearch/osfeedparser.py for details on Mark's license.

Author

Ed Summers [email protected]

opensearch's People

Contributors

edsu avatar boyska avatar smn avatar yuvipanda avatar

Watchers

John Vandenberg avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.