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