mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-01 10:04:12 +08:00
fix
This commit is contained in:
parent
51f0688011
commit
2436e078d6
@ -3,6 +3,7 @@ import requests
|
|||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
import re, os
|
import re, os
|
||||||
from cishu.cishubase import cishubase
|
from cishu.cishubase import cishubase
|
||||||
|
from myutils.utils import simplehtmlparser
|
||||||
|
|
||||||
|
|
||||||
class youdao(cishubase):
|
class youdao(cishubase):
|
||||||
@ -20,17 +21,21 @@ class youdao(cishubase):
|
|||||||
url = "https://dict.youdao.com/result?word={}&lang={}".format(
|
url = "https://dict.youdao.com/result?word={}&lang={}".format(
|
||||||
quote(word), self.srclang
|
quote(word), self.srclang
|
||||||
)
|
)
|
||||||
text = requests.get(
|
text = requests.get(url, proxies=self.proxy).text
|
||||||
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)
|
text = re.sub("<header([\\s\\S]*?)></header>", "", text)
|
||||||
if tip:
|
text = re.sub("<aside([\\s\\S]*?)></aside>", "", text)
|
||||||
tip = tip.group()
|
|
||||||
fnd = fnd.replace(tip, "")
|
text = re.sub("<link([\\s\\S]*?)>", "", text)
|
||||||
style = re.search("<style(.*?)>([\\s\\S]*?)</style>", text)
|
text = re.sub('<script([\\s\\S]*?)src="(.*?)"([\\s\\S]*?)</script>', "", text)
|
||||||
style = style.group()
|
text = re.sub('<div class="lang-tip-con"([\\s\\S]*?)</div>', "", text)
|
||||||
return f'<div style="text-align: center;"><a href="{url}">link</a></div><br>{style}{fnd}'
|
|
||||||
|
text = text.replace(
|
||||||
|
simplehtmlparser(text, "div", '<div class="footer_container"'), ""
|
||||||
|
)
|
||||||
|
text = text.replace(
|
||||||
|
simplehtmlparser(text, "div", '<div class="user-feed_back"'), ""
|
||||||
|
)
|
||||||
|
text = text.replace("min-width: 960px", "")
|
||||||
|
text = text.replace("min-width:960px", "")
|
||||||
|
return text
|
||||||
|
@ -801,6 +801,13 @@ class searchwordW(closeashidewindow):
|
|||||||
|
|
||||||
self.tab = CustomTabBar()
|
self.tab = CustomTabBar()
|
||||||
self.tab.tabBarClicked.connect(self.tabclicked)
|
self.tab.tabBarClicked.connect(self.tabclicked)
|
||||||
|
|
||||||
|
def __(idx):
|
||||||
|
if not self.hasclicked:
|
||||||
|
return
|
||||||
|
self.tabclicked(idx)
|
||||||
|
|
||||||
|
self.tab.currentChanged.connect(__)
|
||||||
self.tabks = []
|
self.tabks = []
|
||||||
self.setCentralWidget(ww)
|
self.setCentralWidget(ww)
|
||||||
self.textOutput = auto_select_webview(self)
|
self.textOutput = auto_select_webview(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user