This commit is contained in:
恍兮惚兮 2024-03-07 21:41:16 +08:00
parent 64596a06f1
commit 33032d0f2a
3 changed files with 52 additions and 0 deletions

View 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

View File

@ -1163,6 +1163,12 @@
"color": "blue",
"type": "dev",
"name": "poe"
},
"dev_phind": {
"use": false,
"color": "blue",
"type": "dev",
"name": "phind"
}
},
"magpie10path":"",

View File

@ -4,6 +4,16 @@
"host": "translate.plausibility.cloud"
}
},
"dev_phind":{
"args":{
"流式输出":false
},
"argstype":{
"流式输出":{
"type": "switch"
}
}
},
"dev_poe":{
"args":{
"流式输出":false