mirror of
https://github.com/RussellChamp/tilde-projects.git
synced 2026-10-28 00:22:34 +00:00
Updated some stuff hey
This commit is contained in:
1 parent
57485f6ffd
commit
d9eac44b35
24 files changed
+292
-57
No files matched your search
@@ -14,7 +14,7 @@ def define(word):
|
||||
|
||||
key = open("/home/krowbar/.secret/key").readline().rstrip()
|
||||
|
||||
def defWord(word):
|
||||
def defWord(word, short = True):
|
||||
defs = []
|
||||
url = 'http://www.dictionaryapi.com/api/v1/references/collegiate/xml/%s?key=%s' % (word, key)
|
||||
soup = BeautifulSoup(urllib.urlopen(url).read(), 'html5lib')
|
||||
@@ -22,4 +22,7 @@ def defWord(word):
|
||||
if entry:
|
||||
for d in entry.find_all('dt'):
|
||||
defs.append(d.text.encode('ascii', 'ignore'))
|
||||
return defs
|
||||
if short:
|
||||
return ' '.join(defs)
|
||||
else:
|
||||
return defs
|
||||
Reference in new issue
Block a user