-
#!/usr/local/bin/python
-
-
import requests
-
from bs4 import BeautifulSoup
-
-
-
def youdao(word):
-
url = r'{0}'.format(word.strip())
-
r = requests.get(url)
-
if r.ok:
-
soup = BeautifulSoup(r.content)
-
div = soup.find_all('div', class_='trans-container')[:1]
-
ul = BeautifulSoup(str(div[0]))
-
li = ul.find_all('li')
-
for mean in li:
-
print mean.text
-
-
def query():
-
print('Created by @littlepy, QQ:185635687')
-
while True:
-
word = raw_input('>>>')
-
youdao(word)
-
-
if __name__ == '__main__':
- query()