mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
fix
This commit is contained in:
parent
51f0688011
commit
2436e078d6
@ -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('<section class="modules"(.*?)>([\\s\\S]*?)</section>', text)
|
||||
fnd = fnd.group()
|
||||
text = requests.get(url, proxies=self.proxy).text
|
||||
|
||||
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 f'<div style="text-align: center;"><a href="{url}">link</a></div><br>{style}{fnd}'
|
||||
text = re.sub("<header([\\s\\S]*?)></header>", "", text)
|
||||
text = re.sub("<aside([\\s\\S]*?)></aside>", "", text)
|
||||
|
||||
text = re.sub("<link([\\s\\S]*?)>", "", text)
|
||||
text = re.sub('<script([\\s\\S]*?)src="(.*?)"([\\s\\S]*?)</script>', "", text)
|
||||
text = re.sub('<div class="lang-tip-con"([\\s\\S]*?)</div>', "", text)
|
||||
|
||||
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.tabBarClicked.connect(self.tabclicked)
|
||||
|
||||
def __(idx):
|
||||
if not self.hasclicked:
|
||||
return
|
||||
self.tabclicked(idx)
|
||||
|
||||
self.tab.currentChanged.connect(__)
|
||||
self.tabks = []
|
||||
self.setCentralWidget(ww)
|
||||
self.textOutput = auto_select_webview(self)
|
||||
|
Loading…
x
Reference in New Issue
Block a user