Created
October 23, 2009 03:36
-
-
Save relrod/216617 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#@ Ricky Elrod - lol.py | |
#@ Modified: Thu Oct 22 23:35:56 EDT 2009 | |
#@ vim:ts=3 shiftwidth=3 | |
###### Welcome to LolDefine ###### | |
import sys, os | |
from urllib2 import urlopen, quote | |
from BeautifulSoup import BeautifulStoneSoup | |
while True: | |
cmd = raw_input('Define> ') | |
if cmd == "!help": | |
print """ | |
Welcome to LolDefine, by CodeBlock. | |
To get the definition of a word, type the word at the Define> prompt. | |
To see a list of dictionaries which you can use, type !dict list. <NOT IMPLEMENTED> | |
To change to one, use !dict <DICT_NAME>. <NOT IMPLEMENTED> | |
""" | |
continue | |
elif cmd == "!exit" or cmd == "!quit" or cmd == "/quit": | |
print "Quitting on user request." | |
sys.exit() | |
elif cmd == "!clear" or cmd == "/clear": | |
if os.name == "posix": | |
os.system("clear") | |
elif os.name in ("nt","dos","ce"): | |
os.system("cls") | |
else: | |
try: | |
cmd = quote(cmd) | |
definition = urlopen("http://services.aonaware.com//DictService/DictService.asmx/DefineInDict?dictId=wn&word="+cmd) | |
parse = BeautifulStoneSoup(definition) | |
print parse('worddefinition',limit=2)[1].string | |
except IndexError: | |
print "Definition not found." | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment