From b5745008881fd1e6be2da8d94514d0c4ec9f6d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Mon, 17 Jun 2024 18:38:39 +0800 Subject: [PATCH] yd --- LunaTranslator/LunaTranslator/cishu/youdao.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/LunaTranslator/LunaTranslator/cishu/youdao.py b/LunaTranslator/LunaTranslator/cishu/youdao.py index 1696e181..d6e3cb9f 100644 --- a/LunaTranslator/LunaTranslator/cishu/youdao.py +++ b/LunaTranslator/LunaTranslator/cishu/youdao.py @@ -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('
([\\s\\S]*?)
', text) fnd = fnd.group() + + tip = re.search('
', fnd) + if tip: + tip = tip.group() + fnd = fnd.replace(tip, "") style = re.search("([\\s\\S]*?)", text) style = style.group() - return '
link

{}{}'.format( - "https://dict.youdao.com/result?word={}&lang={}".format( - quote(word), self.srclang - ), - style, - fnd, - ) + return f'
link

{style}{fnd}'