From 2436e078d6bfda302e93f09af25522d087b4e56a 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: Sat, 17 Aug 2024 22:04:38 +0800 Subject: [PATCH] fix --- LunaTranslator/LunaTranslator/cishu/youdao.py | 31 +++++++++++-------- LunaTranslator/LunaTranslator/gui/showword.py | 7 +++++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/LunaTranslator/LunaTranslator/cishu/youdao.py b/LunaTranslator/LunaTranslator/cishu/youdao.py index d6e3cb9f..1736551a 100644 --- a/LunaTranslator/LunaTranslator/cishu/youdao.py +++ b/LunaTranslator/LunaTranslator/cishu/youdao.py @@ -3,6 +3,7 @@ import requests from urllib.parse import quote import re, os from cishu.cishubase import cishubase +from myutils.utils import simplehtmlparser class youdao(cishubase): @@ -20,17 +21,21 @@ class youdao(cishubase): url = "https://dict.youdao.com/result?word={}&lang={}".format( quote(word), self.srclang ) - text = requests.get( - url, - proxies=self.proxy, - ).text - fnd = re.search('
([\\s\\S]*?)
', text) - fnd = fnd.group() + text = requests.get(url, proxies=self.proxy).text - tip = re.search('
', fnd) - if tip: - tip = tip.group() - fnd = fnd.replace(tip, "") - style = re.search("([\\s\\S]*?)", text) - style = style.group() - return f'
link

{style}{fnd}' + text = re.sub("", "", text) + text = re.sub("", "", text) + + text = re.sub("", "", text) + text = re.sub('', "", text) + text = re.sub('
', "", text) + + text = text.replace( + simplehtmlparser(text, "div", '