AI Translate

FREEMIUM
By binbin he | Updated a month ago | Translation
Popularity

9.8 / 10

Latency

649ms

Service Level

100%

Health Check

100%

Back to All Discussions

Return nothing when trying to translate an html document using python

Rapid account: Bragandassi
bragandassi
a year ago

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 a year ago

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)

Join in the discussion - add comment below:

Login / Signup to post new comments