Форум: "Сети";
Текущий архив: 2004.04.18;
Скачать: [xml.tar.bz2];
ВнизВыполнение строки http Найти похожие ветки
← →
vitas_tomsk © (2004-02-16 10:40) [0]Как выполнить http строку и получить результат ?
← →
easy © (2004-02-16 14:35) [1]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
Thttpstring = string;
type
TForm1 = class(TForm)
ClientSocket1: TClientSocket;
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
procedure ClientSocket1Disconnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure FormCreate(Sender: TObject);
private
response: string;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ClientSocket1.Open;
end;
procedure TForm1.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
var
s: string;
httpstring: Thttpstring;
begin
httpstring := "/cgi-bin/forum.pl?id=1076917247&n=4";
s := "GET " + httpstring + " HTTP/1.0" +
"Accept: */*" +
"Referer: http://www.delphimaster.ru/cgi-bin/forum.pl?n=4" +
"Accept-Language: ru" +
"Proxy-Connection: Keep-Alive" +
"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" +
"Host: www.delphimaster.ru" +
"Pragma: no-cache"#10#10;
response := "";
Socket.SendText(s);
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
response := response + Socket.ReceiveText;
end;
procedure TForm1.ClientSocket1Disconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Text := response;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ClientSocket1.Port := 80;
ClientSocket1.Host := "www.delphimaster.ru";
memo1.ScrollBars := ssVertical;
memo1.Clear;
end;
end.
← →
easy © (2004-02-16 15:15) [2]вот такая штука ешё -
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, wininet, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
hSession, hConnect, hRequest: hInternet;
Header, httpstring: string;
Buf: array[0..1023] of Char;
ReadCount: Cardinal;
AStream: TMemoryStream;
begin
Header := "Content-type: application/x-www-form-urlencoded";
httpstring := "/cgi-bin/forum.pl?id=1076917247&n=4";
AStream := TMemoryStream.Create;
hSession := InternetOpen(nil, INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
hConnect := InternetConnect(hSession, "delphimaster.ru",
INTERNET_DEFAULT_HTTP_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
try
hRequest := HttpOpenRequest(hConnect, "GET",
pchar(httpstring), "HTTP/1.0", nil, nil,
INTERNET_FLAG_RELOAD, 0);
try
HttpSendRequest(hRequest, Pchar(Header),
Length(Header), nil, 0);
while True do
begin
if not InternetReadFile(hRequest, @Buf, SizeOf(Buf), ReadCount) then
Break;
if ReadCount = 0 then
Break
else
AStream.Write(Buf, ReadCount);
end;
AStream.Position := 0;
memo1.Lines.LoadFromStream(AStream);
finally
AStream.Free;
InternetCloseHandle(hRequest);
end;
finally
InternetCloseHandle(hConnect);
end;
finally
InternetCloseHandle(hSession);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.ScrollBars := ssVertical;
memo1.Clear;
end;
end.
← →
easy © (2004-02-16 15:54) [3]
program Project1;
uses
ComObj,
activex;
const
csOLEObjName = "InternetExplorer.Application";
var
IE: Variant;
httpstring: string;
begin
httpstring := "http://delphimaster.net/view/6-1076917247/";
CoInitialize(nil);
IE := CreateOleObject(csOLEObjName);
IE.Visible := true;
IE.Navigate(httpstring);
end.
Страницы: 1 вся ветка
Форум: "Сети";
Текущий архив: 2004.04.18;
Скачать: [xml.tar.bz2];
Память: 0.48 MB
Время: 0.04 c