Главная страница
    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.038 c
1-1080848872
mike_forewer
2004-04-01 23:47
2004.04.18
Сортировка в TStringGrid


1-1080341683
ceval
2004-03-27 01:54
2004.04.18
Подскажите как программно в RadioGroup написать название


1-1080594387
Pavel
2004-03-30 01:06
2004.04.18
Timer


4-1076693612
DelphiN!
2004-02-13 20:33
2004.04.18
Работа с реестром


1-1080536318
race1
2004-03-29 08:58
2004.04.18
findnextprinterchangenotification





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский