mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
phind
This commit is contained in:
parent
64596a06f1
commit
33032d0f2a
36
LunaTranslator/LunaTranslator/translator/dev_phind.py
Normal file
36
LunaTranslator/LunaTranslator/translator/dev_phind.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import json
|
||||||
|
from translator.basetranslator_dev import basetransdev
|
||||||
|
import time
|
||||||
|
|
||||||
|
class TS(basetransdev):
|
||||||
|
target_url='https://www.phind.com/agent'
|
||||||
|
def langmap(self):
|
||||||
|
return {'zh': 'Simplified Chinese', 'ja': 'Japanese', 'en': 'English', 'ru': 'Russian', 'es': 'Spanish', 'ko': 'Korean', 'fr': 'French', 'cht': 'Traditional Chinese', 'vi': 'Vietnamese', 'tr': 'Turkish', 'pl': 'Polish', 'uk': 'Ukrainian', 'it': 'Italian', 'ar': 'Arabic', 'th': 'Thai'}
|
||||||
|
def translate(self,content):
|
||||||
|
content='Please help me translate the following {} text into {}, and you should only tell me the translation.\n'.format(self.srclang,self.tgtlang)+content
|
||||||
|
|
||||||
|
num=self.wait_for_result('''document.querySelector("#__next > div > div > div.col-lg-12.sidebar > main > div > div > div > div > div.mt-8").children.length''')
|
||||||
|
if num==1:
|
||||||
|
num=0
|
||||||
|
self.Runtime_evaluate('''document.querySelector("#__next > div > div > div.col-lg-12.sidebar > main > div > div > div > div > div.fixed-bottom.bg-gradient-light > div > div > div.col-12 > div > form > div > textarea").click()''')
|
||||||
|
self.send_keys(content)
|
||||||
|
self.Runtime_evaluate('''document.querySelector("#__next > div > div > div.col-lg-12.sidebar > main > div > div > div > div > div.fixed-bottom.bg-gradient-light > div > div > div.col-12 > div > form > div > div > button").click()''')
|
||||||
|
if self.config['流式输出']==False:
|
||||||
|
self.wait_for_result('''document.querySelector("#__next > div > div > div.col-lg-12.sidebar > main > div > div > div > div > div.fixed-bottom.bg-gradient-light > div > div > div.col-12 > div > button")''') #不为null时会exception continue
|
||||||
|
yield self.wait_for_result('''document.querySelector("#__next > div > div > div.col-lg-12.sidebar > main > div > div > div > div > div.mt-8 > div:nth-child({}) > div > div > div > div:nth-child(1) > div:nth-child(3)").textContent'''.format(num+2))
|
||||||
|
else:
|
||||||
|
currtext=''
|
||||||
|
while True:
|
||||||
|
time.sleep(0.1)
|
||||||
|
newcurr=self.wait_for_result('''document.querySelector("#__next > div > div > div.col-lg-12.sidebar > main > div > div > div > div > div.mt-8 > div:nth-child({}) > div > div > div > div:nth-child(1) > div:nth-child(3)").textContent'''.format(num+2))
|
||||||
|
if newcurr=='...':continue
|
||||||
|
yield newcurr[len(currtext):]
|
||||||
|
currtext=newcurr
|
||||||
|
if 'className' not in (self.Runtime_evaluate('''document.querySelector("#__next > div > div > div.col-lg-12.sidebar > main > div > div > div > div > div.fixed-bottom.bg-gradient-light > div > div > div.col-12 > div > button")'''))['result']:
|
||||||
|
newcurr=self.wait_for_result('''ddocument.querySelector("#__next > div > div > div.col-lg-12.sidebar > main > div > div > div > div > div.mt-8 > div:nth-child({}) > div > div > div > div:nth-child(1) > div:nth-child(3)").textContent'''.format(num+2))
|
||||||
|
yield newcurr[len(currtext):]
|
||||||
|
break
|
||||||
|
|
||||||
|
|
@ -1163,6 +1163,12 @@
|
|||||||
"color": "blue",
|
"color": "blue",
|
||||||
"type": "dev",
|
"type": "dev",
|
||||||
"name": "poe"
|
"name": "poe"
|
||||||
|
},
|
||||||
|
"dev_phind": {
|
||||||
|
"use": false,
|
||||||
|
"color": "blue",
|
||||||
|
"type": "dev",
|
||||||
|
"name": "phind"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"magpie10path":"",
|
"magpie10path":"",
|
||||||
|
@ -4,6 +4,16 @@
|
|||||||
"host": "translate.plausibility.cloud"
|
"host": "translate.plausibility.cloud"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dev_phind":{
|
||||||
|
"args":{
|
||||||
|
"流式输出":false
|
||||||
|
},
|
||||||
|
"argstype":{
|
||||||
|
"流式输出":{
|
||||||
|
"type": "switch"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dev_poe":{
|
"dev_poe":{
|
||||||
"args":{
|
"args":{
|
||||||
"流式输出":false
|
"流式输出":false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user