diff options
author | pab <devnull@localhost> | 2009-06-20 19:55:47 +0000 |
---|---|---|
committer | pab <devnull@localhost> | 2009-06-20 19:55:47 +0000 |
commit | 4c53320d77d8f74aa9a8b85a7bd75881c67f2120 (patch) | |
tree | 7a548b413d58218fe863ee1e3b0da7e06b1b0825 /examples/dictionary | |
parent | 898d195ce81429879d1631f4e85c13af2dd99414 (diff) |
Add another example
Diffstat (limited to 'examples/dictionary')
-rw-r--r-- | examples/dictionary/define.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/dictionary/define.py b/examples/dictionary/define.py new file mode 100644 index 0000000..91a3cdc --- /dev/null +++ b/examples/dictionary/define.py @@ -0,0 +1,20 @@ +import dict +import urllib2 +import pyxb.utils.domutils as domutils +from xml.dom import minidom +import sys + +word = 'python' +if 1 < len(sys.argv): + word = sys.argv[1] + +# Create a REST-style query to retrieve the information about this dictionary. +uri = 'http://services.aonaware.com/DictService/DictService.asmx/Define?word=%s' % (word,) +rxml = urllib2.urlopen(uri).read() +resp = dict.CreateFromDOM(domutils.StringToDOM(rxml)) + +print 'Definitions of %s:' % (resp.Word(),) +for definition in resp.Definitions().Definition(): + print 'From %s (%s):' % (definition.Dictionary().Name(), definition.Dictionary().Id()) + print definition.WordDefinition() + print |