import os
import requests as RS
from bs4 import BeautifulSoup as BS
def qqq(word):
# 金山词霸
url = “http://www.iciba.com/“
# word = input(“输入你想要翻译的单词和词:“)
filename = open(“lingyun.txt““a+“)
if word == ““:
return “宝贝:不能为空哦!!!“
try:
page = RS.get(url+word)
con = page.content
soup = BS(con“lxml“)
key = soup.find(“h1“class_=“keyword“)
if key is None:
key = soup.find(“h1“ style=“width: 580px; margin-top: 15px; font-size: 15px; line-height: 24px; color: #897f6b;“)
if key is None:
key = soup.find(“h1“ style=“width: 580px; margin-top: 15px; font-size: 18px; line-height: 26px; color: #897f6b;“)
print(key.contents[0])
filename.write(key.conte
评论
共有 条评论