ActiveState Code

Recipe 56034: Using xml-rpc


This simple recipe shows how you can pull recipes from O'Reilly's meerkat service using xml-rpc.

Python
1
2
3
4
5
6
7
8
9
from xmlrpclib import Server
from pprint import pprint

query = {'search':'Python', 'time_period':'7DAYS',}
meerkatURI = 'http://www.oreillynet.com/meerkat/xml-rpc/server.php'

meerkatSrv = Server(meerkatURI)
data = meerkatSrv.meerkat.getItems(query)
pprint(data)

Discussion

This is a simple xml-rpc recipe to call Meerkat the OReilly resource centre. It passes two arguments: search and time_period in a dict. meerkatSrv is an instance of the xml-rpc server, we then call the method getItems on meerkat, passing through query.

More information on Meerkat can be found at: http://www.oreillynet.com/meerkat/.

I run this script regularly with a slight modification, the data is parsed into html and loaded into my browser so I can click on links to the articles.

Comments

  1. 1. At 3:28 a.m. on 11 jun 2001, Hamish Lawson said:

    Information on where to get xmlrpclib. Perhaps it should be mentioned that xmlrpclib is not in the standard library; it may be useful to give details of how it may be obtained (refer to the Vaults of Parnassus?).

  2. 2. At 4:31 p.m. on 17 jul 2001, David Brown said:

    xmlrpclib to be included in Python 2.2. It has been checked in to the source tree for Python 2.2, until then you can get it at Python Labs here: http://www.pythonware.com/downloads/index.htm#xmlrpc

  3. 3. At 7:25 a.m. on 25 jul 2001, Greg Wilson said:

    Duplicate text in example? Is the text of the example correct? Everything from the second import of "pprint" down seems to duplicate the first few lines.

  4. 4. At 5:13 p.m. on 16 aug 2001, andy mckay (the author) said:

    Duplicated text. Oops, thanks.

Sign in to comment