AI Translate

フリーミアム
よって binbin he | 更新済み 5 days ago | Translation
人気

9.8 / 10

レイテンシー

738ms

サービスレベル

100%

Health Check

100%

すべてのディスカッションに戻る

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)

ディスカッションに参加しましょう-以下にコメントを追加してください:

ログイン/サインアップして新しいコメントを投稿