我正在尝试制作一个 python 脚本来使用 DeepL API 进行翻译。我尝试发出请求,但它响应 HTTP 错误 400(错误请求)。
这是我的脚本代码,我用以下代码替换了真正的身份验证密钥XXX:
import requests
url = "https://api.deepl.com"
auth_key = {
'host' : "https://api.deepl.com/v2/translate?",
'auth_key':"auth_key=XXX"
}
querystring = {
"text" : "Che bellissima giornata",
"target_lang" : "en"
}
response = requests.request("POST", url, headers=auth_key, data=querystring)
print(response)
print(response.text)
Run Code Online (Sandbox Code Playgroud)