unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ScktComp, StdCtrls;
type
TForm1 = class(TForm)
ClientSocket: TClientSocket;
btnLink: TButton;
btnSend: TButton;
Memo: TMemo;
Edit: TEdit;
Button1: TButton;
procedure btnLinkClick(Sender: TObject);
procedure btnSendClick(Sender: TObject);
procedure ClientSocketRead(Sender: TObject; Socket: TCustomWinSocket);
procedure ClientSocketConnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Var
f:File;
procedure TForm1.btnLinkClick(Sender: TObject);
begin
AssignFile(f,'out.txt');
Rewrite(F,1);
Memo.Lines.Clear;
ClientSocket.Open;
end;
procedure TForm1.btnSendClick(Sender: TObject);
begin
ClientSocket.Socket.SendText('GET /'+Edit.Text+#$0A);
end;
procedure TForm1.ClientSocketRead(Sender: TObject;
Socket: TCustomWinSocket);
Var
s:String;
begin
If Socket.Connected Then
Begin
s:=Socket.ReceiveText;
Memo.Lines.Add(s);
BlockWrite(F,s[1],Length(s));
End;
end;
procedure TForm1.ClientSocketConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo.Lines.Add('AAAAAConn');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ClientSocket.Close;
CloseFile(f);
end;
end.
把数据从取得的网页里分离就不要我讲了吧。