网上找了一些资料,是用indy的组件来post数据包,看的有点迷糊了,基本懂一些,但是不会写。我吧数据包截下来了 麻烦高手写个代码 谢谢================================
POST /post/index.php HTTP/1.1
Accept: application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/QVOD, application/QVOD, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
Referer: http://localhost/post/index.php
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; CIBA; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Host: localhost
Content-Length: 31
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: rtime30012337=0; ltime30012337=1299068773250; cnzz_eid30012337=85842816-1299064835-; AJSTAT_ok_times=1; rtime=2; ltime=1300199150812; cnzz_eid=5865812-1299407386-http%3A//localhost/sohuido/dede/makehtml_homepage.php; PHPSESSID=9i1pb59nbl6ip3583pkpec2r57name=333333&submit=%CC%E1%BD%BB
======================================以上就是数据包了,请问如何使用delphi吧数据 post上去
POST /post/index.php HTTP/1.1
Accept: application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/QVOD, application/QVOD, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
Referer: http://localhost/post/index.php
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; CIBA; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Host: localhost
Content-Length: 31
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: rtime30012337=0; ltime30012337=1299068773250; cnzz_eid30012337=85842816-1299064835-; AJSTAT_ok_times=1; rtime=2; ltime=1300199150812; cnzz_eid=5865812-1299407386-http%3A//localhost/sohuido/dede/makehtml_homepage.php; PHPSESSID=9i1pb59nbl6ip3583pkpec2r57name=333333&submit=%CC%E1%BD%BB
======================================以上就是数据包了,请问如何使用delphi吧数据 post上去
list.Add('name=333333');
list.Add('submit=%CC%E1%BD%BB');
IdHTTP1.Request.Referer := 'http://localhost/post/index.php';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.UserAgent := '';
IdHTTP1.Post(url, list);
Var
Response:string;
Paramstr:Tstringlist;
IdHTTP1:Tidhttp;
begin
IdHTTP1:=Tidhttp.create(nil);
Paramstr:= TStringList.Create;
Paramstr.Add('name=333333');
Paramstr.Add('submit=%CC%E1%BD%BB');
IdHTTP1.Request.Referer := 'http://localhost/post/index.php';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; CIBA; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)';
Response:=IdHTTP1.Post(url, Paramstr);
showmessage(Response);
Freeandnil(IdHTTP1);
Paramstr.Free;
end;
process stopped use step or run to continue不知道如何解决啊
在Interface的uses里加入idhttp;
然后在Button1的Click事件里写入下边代码,我这里没有问题!
Var
Response:string;
Paramstr:Tstringlist;
IdHTTP1:Tidhttp;
begin
IdHTTP1:=Tidhttp.create(nil);
Paramstr:= TStringList.Create;
Paramstr.Add('name=333333');
Paramstr.Add('submit=%CC%E1%BD%BB');
IdHTTP1.Request.Referer := 'http://localhost/post/index.php';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; CIBA; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)';
Response:=IdHTTP1.Post(url, Paramstr);
showmessage(Response);
Freeandnil(IdHTTP1);
Paramstr.Free;
end;
然后一个错误 就是上面那个了 我就不会改了麻烦老兄试试看哈。