本文整理自网络,侵删。

function GetTranslatedText(const OriText: string): string;var Json: TQJson;const WebRestApiUrl = 'http://fanyi.youdao.com/translate?&doctype=json&type=AUTO&i=%s';begin Json := TQJson.Create; try try Json.Parse(CSimpleGet(Format(WebRestApiUrl, [TURLEncoding.URL.Encode(OriText)]))); //CSimpleGet 这里可以搜索本站用 idhttp nethttpclient 实现获取 Result := Json.ItemByPath('\translateResult[0][0]\tgt').AsString; except on e: Exception do Result := ''; end; finally FreeAndNil(Json); end;end;
感谢 黑夜杀手 提供
相关阅读 >>
Delphi datasnap(midas)三层架构中,常用事件及其触发顺序
Delphi下cpu getcpuid实现(x86和x64)
Delphi 调用api打开文件 使用系统默认打开方式进行打开
Delphi getwebbrowserhtml 获取网页源代码
更多相关阅读请进入《Delphi》频道 >>