K
koenemy
Unregistered / Unconfirmed
GUEST, unregistred user!
unit SearchBase;
interface
uses
IdHTTP;
type
TSearchBase = class
protected
keyword:String;
companyName:String;
function HttpRequestExecute(Url:string): string;
public
function GetPlace:String;virtual;abstract;
end;
implementation
function TSearchBase.HttpRequestExecute(Url: string): string;
var
Http: TIdHTTP;
begin
Http := TIdHTTP.Create(Nil);
try
Result := Http.Get(Url);
finally
Http.Free;
end;
end;
end.
--------------------------------------------------------------
unit baidu;
interface
uses
SearchBase;
Type
Tbaidu = class(TSearchBase)
public
function GetPlace:String;override;
Constructor Create(vkeyword,vcompanyName:String);
end;
implementation
function Tbaidu.GetPlace:String;
begin
Result := HttpRequestExecute('http://www.sina.com.cn');
end;
Constructor Tbaidu.Create(vkeyword,vcompanyName:String);
begin
keyword := vkeyword;
companyName := vcompanyName;
end;
end.
---------------------------------------------------------------------------
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP,SearchBase,baidu, StdCtrls;
type
TForm1 = class(TForm)
mmo1: TMemo;
btn1: TButton;
edt1: TEdit;
edt2: TEdit;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
TS:TSearchBase;
TSon:Tbaidu;
begin
TS:=TSon.Create(edt1.Text,edt2.Text);
mmo1.Text := TS.GetPlace();
end;
end.
interface
uses
IdHTTP;
type
TSearchBase = class
protected
keyword:String;
companyName:String;
function HttpRequestExecute(Url:string): string;
public
function GetPlace:String;virtual;abstract;
end;
implementation
function TSearchBase.HttpRequestExecute(Url: string): string;
var
Http: TIdHTTP;
begin
Http := TIdHTTP.Create(Nil);
try
Result := Http.Get(Url);
finally
Http.Free;
end;
end;
end.
--------------------------------------------------------------
unit baidu;
interface
uses
SearchBase;
Type
Tbaidu = class(TSearchBase)
public
function GetPlace:String;override;
Constructor Create(vkeyword,vcompanyName:String);
end;
implementation
function Tbaidu.GetPlace:String;
begin
Result := HttpRequestExecute('http://www.sina.com.cn');
end;
Constructor Tbaidu.Create(vkeyword,vcompanyName:String);
begin
keyword := vkeyword;
companyName := vcompanyName;
end;
end.
---------------------------------------------------------------------------
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP,SearchBase,baidu, StdCtrls;
type
TForm1 = class(TForm)
mmo1: TMemo;
btn1: TButton;
edt1: TEdit;
edt2: TEdit;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
TS:TSearchBase;
TSon:Tbaidu;
begin
TS:=TSon.Create(edt1.Text,edt2.Text);
mmo1.Text := TS.GetPlace();
end;
end.