Delphi MsXML 获取 API接口


本文整理自网络,侵删。

 
uses MsXML, SuperObject;


//字符串到 UTF8 编码的函数, 用于 Google 地址
function ToUTF8Encode(str: string): string;
var
  b: Byte;
begin
  for b in BytesOf(UTF8Encode(str)) do
    Result := Format('%s%s%.2x', [Result, '%', b]);
end;


//翻译函数
function Translate(str, RequestLanguage, ResultLanguage: string): string;
const
  BaseUrl = 'http://fanyi.youdao.com/translate?&doctype=json&version&i=';
var
  Url: string;
  jo: ISuperObject;
  req: IXMLHTTPRequest;
begin
  Url := BaseUrl + ToUTF8Encode(str) ;
  req := CoXMLHTTP.Create;
  req.open('Get', Url, False, EmptyParam, EmptyParam);
  req.send(EmptyParam);
 // jo := SO(req.responseText);
  Result := req.responseText;//jo.Format('%translateResult%');
end;

相关阅读 >>

Delphi_关于null,nil

Delphi idtcpclient1实现端口扫描器

Delphi datasnap http用法注意事项

Delphi richedit中插入带背景色文本的一种思路

Delphi ioutils单元3查找并搜索文件夹信息

Delphi有用的函数extractfilename、extractfilepath

如何用Delphi实现子目录级的文件查询

Delphi 中使用dialog api

线程池的概念

Delphi idhttp上传图给asp完美解决

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...