[delphi]indy10 idhttp get方法
2014-12-19 12:50
169 查看
idhttp中对于get方法的定义:
[delphi] view
plaincopyprint?
procedure Get(AURL: string; AResponseContent: TStream); overload;
procedure Get(AURL: string; AResponseContent: TStream; AIgnoreReplies: array of SmallInt);
overload;
function Get(AURL: string): string; overload;
function Get(AURL: string; AIgnoreReplies: array of SmallInt): string; overload;
其中的最基本的方法是过程类方法
[delphi] view
plaincopyprint?
procedure Get(AURL: string; AResponseContent: TStream; AIgnoreReplies: array of SmallInt);
overload;
其他的几个get方法重载都是基于嵌套的此方法。
参数:
[python] view
plaincopyprint?
AURL: string; // get操作的目标URL
AResponseContent: TStream; // 返回流
AIgnoreReplies: array of SmallInt; // 忽略掉出现这些http状态码的错误
示例代码:
[delphi] view
plaincopyprint?
unit UMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, StdCtrls;
type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Memo1: TMemo;
btnGetOne: TButton;
btnGetTwo: TButton;
btnGetThree: TButton;
btnGetFour: TButton;
procedure btnGetOneClick(Sender: TObject);
procedure btnGetTwoClick(Sender: TObject);
procedure btnGetThreeClick(Sender: TObject);
procedure btnGetFourClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
Cgeturl = 'http://www.soso.com/';
C302url = 'http://soso.com/';
var
RespData : TStringStream;
procedure TForm1.btnGetOneClick(Sender: TObject);
begin
RespData := TStringStream.Create('');
IdHTTP1.Get(Cgeturl, RespData);
Memo1.Text := RespData.DataString;
end;
procedure TForm1.btnGetTwoClick(Sender: TObject);
begin
RespData := TStringStream.Create('');
IdHTTP1.Get(C302url, RespData, [302]);
Memo1.Text := RespData.DataString;
end;
procedure TForm1.btnGetThreeClick(Sender: TObject);
begin
Memo1.Text := IdHTTP1.Get(Cgeturl);
end;
procedure TForm1.btnGetFourClick(Sender: TObject);
begin
Memo1.Text := IdHTTP1.Get(C302url, [302]);
end;
end.
[delphi] view
plaincopyprint?
procedure Get(AURL: string; AResponseContent: TStream); overload;
procedure Get(AURL: string; AResponseContent: TStream; AIgnoreReplies: array of SmallInt);
overload;
function Get(AURL: string): string; overload;
function Get(AURL: string; AIgnoreReplies: array of SmallInt): string; overload;
其中的最基本的方法是过程类方法
[delphi] view
plaincopyprint?
procedure Get(AURL: string; AResponseContent: TStream; AIgnoreReplies: array of SmallInt);
overload;
其他的几个get方法重载都是基于嵌套的此方法。
参数:
[python] view
plaincopyprint?
AURL: string; // get操作的目标URL
AResponseContent: TStream; // 返回流
AIgnoreReplies: array of SmallInt; // 忽略掉出现这些http状态码的错误
示例代码:
[delphi] view
plaincopyprint?
unit UMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, StdCtrls;
type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Memo1: TMemo;
btnGetOne: TButton;
btnGetTwo: TButton;
btnGetThree: TButton;
btnGetFour: TButton;
procedure btnGetOneClick(Sender: TObject);
procedure btnGetTwoClick(Sender: TObject);
procedure btnGetThreeClick(Sender: TObject);
procedure btnGetFourClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
Cgeturl = 'http://www.soso.com/';
C302url = 'http://soso.com/';
var
RespData : TStringStream;
procedure TForm1.btnGetOneClick(Sender: TObject);
begin
RespData := TStringStream.Create('');
IdHTTP1.Get(Cgeturl, RespData);
Memo1.Text := RespData.DataString;
end;
procedure TForm1.btnGetTwoClick(Sender: TObject);
begin
RespData := TStringStream.Create('');
IdHTTP1.Get(C302url, RespData, [302]);
Memo1.Text := RespData.DataString;
end;
procedure TForm1.btnGetThreeClick(Sender: TObject);
begin
Memo1.Text := IdHTTP1.Get(Cgeturl);
end;
procedure TForm1.btnGetFourClick(Sender: TObject);
begin
Memo1.Text := IdHTTP1.Get(C302url, [302]);
end;
end.
相关文章推荐
- [delphi]indy10 idhttp get方法
- [delphi]indy10 idhttp get方法
- Delphi Idhttp的 Get 和 Post 方法
- Delphi Idhttp的get和post方法
- delphi IdHTTP实现Get方法下载文件,断点续传
- [delphi]indy idhttp post方法
- [delphi]indy idhttp post方法
- Delphi IDHTTP控件:GET/POST 请求
- Delphi Idhttp的post方法
- delphi的idhttp的get 和 post的使用
- delphi idhttp 使用方法
- delphi的idhttp的get 和 post的使用
- Delphi IDHTTP控件:GET/POST 请求
- delphi的idhttp的get 和 post的使用
- Idhttp Get方法
- delphi idhttp 使用方法
- Delphi IDHTTP控件:GET/POST 请求
- .net调用别人的http页面,返回结果,url中有中文的处理,get和post两种方法
- 使用HTTP GET调用Web Services方法
- 使用t-sql从身份证号中提取生日(转自:http://www.cnblogs.com/yukaizhao/archive/2008/05/22/sql_getbirthday_from_id.html)