Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lingva 修改默认域名 & 允许设置自建实例 #394

Closed
Vinfall opened this issue Sep 2, 2023 · 1 comment
Closed

Lingva 修改默认域名 & 允许设置自建实例 #394

Vinfall opened this issue Sep 2, 2023 · 1 comment

Comments

@Vinfall
Copy link

Vinfall commented Sep 2, 2023

根据 thedaviddelta/lingva-translate#169 ,在线翻译里Lingva默认域名lingva.ml已经被收回,建议改成translate.plausibility.cloud

def inittranslator(self):
res=requests.get('https://lingva.ml/',headers=
{
'sec-ch-ua': '"Not?A_Brand";v="8", "Chromium";v="108", "Microsoft Edge";v="108"',
'Referer': 'https://lingva.ml/',
'sec-ch-ua-mobile': '?0',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.46',
'sec-ch-ua-platform': '"Windows"',
},proxies=self.proxy).text
_id=re.findall('buildId":"(.*?)"',res)[0]
self.url='https://lingva.ml/_next/data/{}/%s/%s/%s.json'.format(_id)
def translate(self,content):
print(self.url%(self.srclang,self.tgtlang,urllib.parse.quote(content)))
x=requests.get(self.url%(self.srclang,self.tgtlang,urllib.parse.quote(content)),headers = {
'authority': 'lingva.ml',
'accept': '*/*',
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'cache-control': 'no-cache',
'pragma': 'no-cache',
'referer': 'https://lingva.ml/',

最好能顺带加个自定义功能,避免使用自建的lingva translate每次都手动替换域名。

@HIllya51
Copy link
Owner

HIllya51 commented Sep 2, 2023

已修

@HIllya51 HIllya51 closed this as completed Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants