This commit is contained in:
恍兮惚兮 2024-06-17 18:38:39 +08:00
parent ecb33ad9cb
commit b574500888

View File

@ -17,20 +17,20 @@ class youdao(cishubase):
return ""
def search(self, word):
url = "https://dict.youdao.com/result?word={}&lang={}".format(
quote(word), self.srclang
)
text = requests.get(
"https://dict.youdao.com/result?word={}&lang={}".format(
quote(word), self.srclang
),
url,
proxies=self.proxy,
).text
fnd = re.search('<section class="modules"(.*?)>([\\s\\S]*?)</section>', text)
fnd = fnd.group()
tip = re.search('<div class="lang-tip-con"(.*?)</div>', fnd)
if tip:
tip = tip.group()
fnd = fnd.replace(tip, "")
style = re.search("<style(.*?)>([\\s\\S]*?)</style>", text)
style = style.group()
return '<div style="text-align: center;"><a href="{}">link</a></div><br>{}{}'.format(
"https://dict.youdao.com/result?word={}&lang={}".format(
quote(word), self.srclang
),
style,
fnd,
)
return f'<div style="text-align: center;"><a href="{url}">link</a></div><br>{style}{fnd}'