delphi 7 http请求转换成字符串 [英] delphi 7 http request into string

查看:432
本文介绍了delphi 7 http请求转换成字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想直接将一个网址加载到没有任何数据流的字符串中,最好的方式是什么, internet open url 有效,但似乎不清楚。

I want to load a url directly into a string without any data stream,what is the best way, internet open url works but it seems not clear.

我不想使用任何组件来阅读一些短信

I don't want to use any component for reading some short messages

推荐答案

Delphi 6及更高版本附带Indy,它有一个 TIdHTTP 客户端组件,例如:

Delphi 6 and later ship with Indy, which has a TIdHTTP client component, eg:

uses
  ..., IdHTTP;

var
  Reply: String;
begin
  Reply := IdHTTP1.Get('http://test.com/postaccepter?=msg1=3444&msg2=test');
    ...
end;

或者:

uses
  ..., IdHTTP;

var
  Reply: TStream;
begin
  Reply := TMemoryStream.Create;
  try
    IdHTTP1.Get('http://test.com/postaccepter?=msg1=3444&msg2=test', Reply);
    Reply.Position := 0;
    ...
  finally
    Reply.Free;
  end;
end;

视乎您的需要而定。

这篇关于delphi 7 http请求转换成字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆