网址 : http://www.cppinfo.com/pdm/business/site/cip/siteAppNo.jsp
验证码地址:http://www.cppinfo.com/pdm/business/site/util/imageForCip.jsp?isDecorator=false
测试id : cip核字号2011075556 再填入验证码 点验证 会有页面数据显示环境 : delphi  7+indy10  winxp sp3  ie8
我是这么做的 先 get 获取 验证码 再模拟post 总是获取不到跳转的页面 代码 :var
  stream:  TStringStream;  s:string;begin
  EditURL.Text :='http://www.cppinfo.com/pdm/business/site/cip/siteAppNo.jsp';
  with IdHTTP do
  begin
    Request.Accept := 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-ms-application, application/x-ms-xbap,'
    + 'application/vnd.ms-xpsdocument, application/xaml+xml, application/x-silverlight, application/msword, */*';
    Request.AcceptEncoding :='gzip, deflate';
    Request.AcceptLanguage :='zh-cn';
    Request.CacheControl :='no-cache';
    Request.Connection :='Keep-Alive';
    Request.ContentLength :=35;
    Request.Host :='www.cppinfo.com';
    Request.Referer :='http://www.cppinfo.com/pdm/business/site/cip/siteAppNo.jsp';
    Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)';
    Request.ContentType := 'application/x-www-form-urlencoded';
    HandleRedirects := true;    AllowCookies :=true;
  end;
  stream:=TStringStream.Create('approveNo=2011075556&captchaNo='+edit2.Text);  try    try    s:=IdHTTP.Post(EditURL.Text, stream );
    Memo1.Clear ;
    Memo1.Lines.Add(s );    except
      ShowMessage('login fail');
    end;  finally
    stream.Free ;
  end;
end;是验证码不对还是 此网站有防护 不可以被模拟post

解决方案 »

  1.   

    你找过wpe,然后在网站上正常提交,看看wpe抓包的内容,跟你自己的比对一下
      

  2.   

    我用的是 httpwatch  IE 上操作 正常  模拟的post 返回的字符串 不是IE上的结果  
      

  3.   

    没看到你POST提交时 带上了验证码的 COOKIE信息
    用WPE 截自己写的程序封包 再跟截浏览器的对比
    这样容易找原因
      

  4.   

    POST的时候带上获取验证码时的Cookie
      

  5.   


    Delphi7在使用idhttp的时候默认是不保存cookie的,要自己将获取验证码的cookie截取后然后
    idhttp.request.customheaders.text:='cookie:' + COOKIE;
    指定后再POST才可以!
    INDY10直接GET验证码然后POST就可以了,不用指定COOKIE!
      

  6.   

    需要整理下思路   界面上我放了  IdCookieManager1 并关联了 idhttp 首先是 get 获取到 验证码图片 这里我保存了一个图片 肉眼识别后 供 post 测试 虽然 get时 确实获取了cookie post 时也带了   但是还是 无法返回IE的 数据 post 之后的 获取的 html 显示 还停留在 验证码提交页并没有 跳转请大家注意 验证码提交页面html post 
    <FORM method=post name=cipForm target=_parent>
    在父窗口打开  是不是 这里的问题 我搞不懂  
    HandleRedirects := true;也设置了
      

  7.   


    wpe 有毒呀 
    另外 我关联了 IdCookieManager1   post时肯定是带上了 cookie