AI Translate

免费增值
通过 binbin he | 已更新 hace 5 días | Translation
人气

9.8 / 10

延迟

738ms

服务等级

100%

Health Check

100%

返回所有讨论

Return nothing when trying to translate an html document using python

Rapid account: Bragandassi
bragandassi
hace un año

This is what i get when tried to translate an html document from english to french:
API response is not a list: {‘code’: 200, ‘texts’: [‘你好。 世界!’, ‘<b>你好。 谷歌!</b>’, ‘<i>你好。 迅速的!</i>’], ‘tl’: ‘zh’}
Please help!

Note: I"m using the API with python script to translate. What did i do wrong?

Rapid account: Haizibinbin Owynt Kc 0 A 48
haizibinbin-owyntKc0a48 Commented hace un año

try this code:

import requests

url = “https://ai-translate.p.rapidapi.com/translates

payload = {
“texts”: [’<a href=“aaaaa.html”>i love code <span>are you?</span> yes<b>i am</b></a>’, “<b>hello. google!</b>”, “<i>hello. rapidapi!</i>”],
“tls”: [“zh”, “ru”],
“sl”: “en”
}
headers = {
“content-type”: “application/json”,
“X-RapidAPI-Key”: “YOUR-API-KEY”,
“X-RapidAPI-Host”: “ai-translate.p.rapidapi.com
}

response = requests.request(“POST”, url, json=payload, headers=headers)

print(response.text)

加入讨论 - 在下面添加评论:

登录/注册以发布新的评论