比如如何将指定的英文内容翻译成中文?
这是 GPT3.5 查询的结果,并且不起作用。
谢谢!
url = "https://translate.google.com";
sourceText = "Hello, world!";
targetLanguage = "zh-CN"; // Chinese Simplified
// Build the HTTP request
postData = "sl=en&tl=" || urlEncode(targetLanguage) || "&text=" || urlEncode(sourceText);
headers = Associative Array("Content-Type", "application/x-www-form-urlencoded", "User-Agent", "Mozilla/5.0");
httpReq = New HTTP Request(
url,
"POST",
headers,
postData
);
// Send the HTTP request and retrieve the response
httpReq.Send();
response = httpReq.ResponseBody();
// Extract the translation
startPos = Pos(response, "<SPAN title="\">", startPos); Translation = Substr(response, startPos, endPos - startPos); // 显示翻译结果 Show("源文本:" || sourceText); Show("翻译:" || Translation);</SPAN>您的示例中使用了许多不正确的函数。我会先使用脚本索引来修复这些问题,然后在需要时再返回这里。