| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 10213 人关注过本帖
标题:DELPHI7 IDHTTP POST登陆3GQQ网站
只看楼主 加入收藏
szfine
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-7-26
收藏
 问题点数:0 回复次数:0 
DELPHI7 IDHTTP POST登陆3GQQ网站
用HTTPWATCH监测登陆http://www.中登陆过程,其POST数据为:
POST /dir/pt.3g. HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*
Referer: http://www.
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) )
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Host: www.
Content-Length: 334
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: transfer=1; auto_proxy=1; cookies=1; mobile=0; cnzz_a30046588=19; sin30046588=none; rtime30046588=0; ltime30046588=1311690057188; cnzz_eid30046588=43887365-1311676841-; PHPSESSID=ec2ee636feb1da101eb71e60b4ced904; c[3g.][/][aW5mb19pbmRleF9hdHQ%3D]=1; c[3g.][/][M2dfbGFzdExvZ2luUXE%3D]=6506507; c[3g.][/][cHRfa3NpZGxz]=8e2a78761834fe9d4ab8885fad311d5e

sid=AcCEzXiVWDXg1O8tT8rr6PCr&qq=6506507&pwd=a42podr8&bid_code=3GQQ&toQQchat=true&login_url=http%3A%2F%2Fpt.3g.

我用DELPHI7写如下代码:
procedure TForm1.Button1Click(Sender: TObject);
var
TmpStr,sid,r:string;  i,p:integer;  info:Tstrings;res:Tstringstream;
begin
  i:=1;
  TmpStr:=idhttp1.Get('http://www.');
  memo1.Clear;
  memo1.Text:=tmpstr;
  p:= Pos('sid=', TmpStr) + Length('sid=');   //取得SID
  TmpStr := Copy(TmpStr, p, Length(TmpStr));
  p := Pos('&amp', TmpStr);
  sid:=trim(copy(TmpStr, 1, P - 1));
  tmpstr:=idhttp1.Get('http://www.'+sid);
  p:= Pos('handleLogin?r=', TmpStr) + Length('handleLogin?r=');    //取得登陆时候的NO
  TmpStr := Copy(TmpStr, p, Length(TmpStr));
  p := Pos('" method', TmpStr);
  r:=trim(copy(TmpStr, 1, P - 1));
    info:=tstringlist.Create;
    res:=tstringstream.Create('');
     info.Add('sid='+sid+'&qq=6506507&pwd=a42podr8&bid_code=3GQQ&toQQchat=true&login_url=http://info50.3g.');
      with IdHTTP1 do
  begin
    Request.SetHeaders;
    HandleRedirects:=true;
     Request.Connection:='Keep-Alive';
    request.UserAgent:='Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) )';
    request.CacheControl:='no-cache';
    request.Accept:='image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*';
    request.Referer:='http://www.'+sid;
    request.Host:='www.';
    HTTPOptions:=HTTPOptions+[hoKeepOrigProtocol];
    try
      post('http://www.'+r,info,res);
      memo1.Lines.Text:=Utf8ToAnsi(res.DataString);
  //    Disconnect;
      info.Free;
      res.Free;
    except
 //     Disconnect;
      info.Free;
      res.Free;
    end;
  end;
end;

结果在MEMO1里显示:
<p align="center">手机腾讯网</p>
<p align="center">
QQ号码不能为空,请输入您要登录的QQ号码
</p>
<p>
<a href="javascript:wap_prev()">返回上一页</a>
</p>

<p><a href="http://www.手机腾讯网</a>-<a href="http://www.导航</a>-<a href="http://www.软件</a>-<a href="http://www.


请问我这个提交问题出在哪?
搜索更多相关主题的帖子: 登陆3GQQ 网站 
2011-07-26 23:27
快速回复:DELPHI7 IDHTTP POST登陆3GQQ网站
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016886 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved