from urllib.request import urlopen as ur
from bs4 import BeautifulSoup as bfs
import requests
def getResult(keyword):
#发起请求
url = "https://cn.bing.com/dict/search?q=" + keyword
#获取源码
content = requests.get(url)
#解析数据
bs=bfs(content.text,"html.parser")
msg=bs.select("div.qdef ul li")
#处理数据
for m in msg:
print(m.text)
if __name__ == '__main__':
while True:
keyword = input("请输入需要翻译的内容:")
getResult(keyword)