Skip to content

Instantly share code, notes, and snippets.

@hungtatai
Created June 17, 2016 14:02
Show Gist options
  • Save hungtatai/dbed290278995694965d452a2e41e88d to your computer and use it in GitHub Desktop.
Save hungtatai/dbed290278995694965d452a2e41e88d to your computer and use it in GitHub Desktop.
from urllib.request import urlopen
import bs4
def dreye_dict(word):
html = urlopen("http://yun.dreye.com/dict_new/dict.php?w=%s" % word).read().decode("utf-8")
bs = bs4.BeautifulSoup(html, "html.parser")
usualExps = bs.select(".sg.block")[0]
# delete all .exp node
[e.extract() for e in usualExps.select(".exp")]
return usualExps.getText().strip()
'''
print(dreye_dict("understand"))
Output:
vt.[W]
理解;懂;熟諳[+wh-]
認識到;了解[+wh-][+(that)]
據聞,獲悉[+(that)][O2]
認為;推斷[+(that)]
將……理解為[+(that)][O2]
將……看作不言自明;省略[H]
vi.[W]
理解;懂得
熟悉[(+about)]
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment