Can I use python to define a word like this:
x=raw_input(\"Enter Word: \")
x=define(x)
print x
Is this possible? If si.. how 2 do it?
T
import re
from urllib2 import urlopen
def define(word):
html = urlopen("http://dictionary.reference.com/browse/" + word + "?s=t").read()
items = re.findall('\s.*?', html, re.S)
defs = [re.sub('<.*?>','', x).strip() for x in items]
for i, d in enumerate(defs):
print '\n', '%s'%(i+1), d
define(raw_input("Enter the word you'd like to define: "))
This is essentially the same idea as the answer given by @SamTubb.
If the dictionary.com does not have a definition for the word you enter, you'll get a HTTPError
.