Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Сети";
Текущий архив: 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.033 c
14-1080226538
ЕвроКар
2004-03-25 17:55
2004.04.18
Вопрос по интергации с IE


1-1080803727
ORMADA
2004-04-01 11:15
2004.04.18
Variant


4-1076441706
Novichok
2004-02-10 22:35
2004.04.18
как запустить exe из Stream


3-1079960574
Карелин Артем
2004-03-22 16:02
2004.04.18
Посоветуйте компонент для создания таблиц в памяти.


14-1080200566
Ega23
2004-03-25 10:42
2004.04.18
По C++ вопрос будет, не бейте сильно :о)





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский