这是我拿来得到网页源码的程序,dfm没有贴,关键在ClientSocketRead
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;
procedure btnLinkClick(Sender: TObject);
procedure btnSendClick(Sender: TObject);
procedure ClientSocketRead(Sender: TObject; Socket: TCustomWinSocket);
procedure ClientSocketConnect(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.btnLinkClick(Sender: TObject);
begin
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);
End;
end;
procedure TForm1.ClientSocketConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo.Lines.Add('AAAAAConn');
end;
end.