but i have some slight problems.... I can post the name with this script but i cant input the pw... or i have to include a cookie.. don't know what it's wrong so it would be n1 if somebody can help me with this...
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, StdCtrls, StrUtils, IdZlibCompressorBase, ZLib, OleCtrls, SHDocVw; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Label1: TLabel; Button2: TButton; Memo1: TMemo; Button3: TButton; WebBrowser1: TWebBrowser; Edit2: TEdit; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private declarations } public { Public declarations } end; type WebRequest = class private strBuff: String; sck: TIdHTTP; prevPage: String; useGZ: Boolean; procedure SetHeader(strRef: String); public constructor Create(UseGZip : Boolean); function Get(strURL, strReferer: String): String; function Post(strURL: String; strPacket: TStringStream; strReferer: String): String; published property LastPage: String read prevPage write prevPage; property CurrentBuffer: String read strBuff write strBuff; property AllowGZip: Boolean read useGZ write useGZ; end; var Form1: TForm1; implementation {$R *.dfm} constructor WebRequest.Create(UseGZip : Boolean); begin sck := TIdHTTP.Create(); useGZ := UseGZip; if useGZ = true then sck.Compressor := TIdZlibCompressorBase.Create(nil); sck.AllowCookies := true; prevPage := 'http://www.google.ca/'; end; function WebRequest.Get(strURL, strReferer: String): String; var strHTML: String; strRet,strDcmp: TStringStream; begin strRet := TStringStream.Create(''); strDcmp := TStringStream.Create(''); SetHeader(strReferer); sck.Get(strURL, strRet); if sck.Response.ContentEncoding = 'gzip' then begin sck.Compressor.DecompressGZipStream( strRet, strDcmp); strHTML := strDcmp.DataString; end else begin strHTML := strRet.DataString; end; prevPage := strURL; strBuff := strHTML; strRet.Free; strDcmp.Free; Result := strHTML; end; function WebRequest.Post(strURL: String; strPacket: TStringStream; strReferer: String): String; var strRet,strDcmp: TStringStream; strHTML: String; begin if sck.Connected = true then begin sck.Disconnect; while sck.Connected = true do Application.ProcessMessages; end; SetHeader(strReferer); strRet := TStringStream.Create(''); strDcmp := TStringStream.Create(''); sck.Post(strURL, strPacket, strRet); if sck.Response.ContentEncoding = 'gzip' then begin sck.Compressor.DecompressGZipStream( strRet, strDcmp); strHTML := strDcmp.DataString; end else begin strHTML := strRet.DataString; end; prevPage := strURL; strBuff := strHTML; strRet.Free; strDcmp.Free; Result := strHTML; end; procedure WebRequest.SetHeader(strRef: String); begin sck.Request.UserAgent := 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3'; sck.Request.Accept := 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/ png,*/*;q=0.5'; sck.Request.AcceptLanguage := 'en-us,en;q=0.5'; sck.Request.AcceptCharSet := 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'; if useGZ = true then sck.Request.AcceptEncoding := 'gzip, deflate'; sck.Request.Referer := strRef; sck.Request.ContentType := 'application/x-www-form-urlencoded'; sck.Request.Connection := 'keep-alive'; end; procedure TForm1.Button1Click(Sender: TObject); var HTTP: WebRequest; strHTML: String; strPost: TStringStream; begin HTTP := WebRequest.Create(false); strPost := TStringStream.Create(''); strPost.WriteString('destination=/ petcentral.phtml'); strPost.WriteString('&username=' + edit1.Text); strPost.WriteString('&password=' + edit2.Text); label1.Caption := 'Loggin in'; strHTML := HTTP.Post('http://www.neopets.com/hi.phtml', strPost, 'http://www.neopets.com/loginpage.phtml'); memo1.Text:=strHTML; memo1.Lines.SaveToFile('C:\test.html'); strHTML := HTTP.Post('http://www.neopets.com/objects.phtml', strPost, 'http://www.neopets.com/hi.phtml'); memo1.Text:=strHTML; memo1.Lines.SaveToFile('C:\test2.html'); end; //Get procedure TForm1.Button2Click(Sender: TObject); var HTTP: WebRequest; strHTML: String; begin HTTP := WebRequest.Create(false); strHTML := HTTP.Get('http://www.neopets.com/petcentral.phtml',HTTP.LastPage); Memo1.Text:=strHTML; end; end.