mirror of
https://github.com/RussellChamp/tilde-projects.git
synced 2026-10-28 08:32:32 +00:00
Some recent changes and stuff
This commit is contained in:
1 parent
ebb5f2fe37
commit
86916fb5fa
18 files changed
+321
-30
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import urllib
|
||||
from bs4 import BeautifulSoup
|
||||
import random
|
||||
|
||||
def define(word):
|
||||
defs = []
|
||||
url = 'http://www.merriam-webster.com/dictionary/%s' % word
|
||||
soup = BeautifulSoup(urllib.urlopen(url).read(), 'html.parser')
|
||||
head = soup.find('div', id='headword')
|
||||
if head:
|
||||
for p in head.find_all('p'):
|
||||
defs.append(p.text.encode('ascii', 'ignore'))
|
||||
return defs
|
||||
|
||||
key = open("/home/krowbar/.secret/key").readline().rstrip()
|
||||
|
||||
def defWord(word):
|
||||
defs = []
|
||||
url = 'http://www.dictionaryapi.com/api/v1/references/collegiate/xml/%s?key=%s' % (word, key)
|
||||
soup = BeautifulSoup(urllib.urlopen(url).read(), 'html5lib')
|
||||
entry = soup.find('entry')
|
||||
if entry:
|
||||
for d in entry.find_all('dt'):
|
||||
defs.append(d.text.encode('ascii', 'ignore'))
|
||||
return defs
|
||||
Reference in new issue
Block a user