This simple recipe shows how you can pull recipes from O'Reilly's meerkat service using xml-rpc.
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)
|
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.
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?).
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
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.
Duplicated text. Oops, thanks.