我用idhttp 做的POST发包的软件 每次都提示验证码不正确 我个人感觉是验证码不同步。意思软件应该提交的验证码是新的验证码 而软件上面显示的是旧的验证码下面是我的代码 希望大家指正 修改的地方
////////////////////////////////////////
function   CanGetIECookie(const   URL:string;   var   Cookie:string):boolean;
var   lpvBuffer:array[0..1000]   of   byte;
        lpdwBufferLength:cardinal;
begin
    lpdwBufferLength:=sizeof(lpvBuffer);
    result:=InternetGetCookie(PChar(URL),nil,@lpvBuffer,lpdwBufferLength);
    if   result   then
      Cookie:=pchar(@lpvBuffer);
end;procedure TForm1.Button1Click(Sender: TObject);
var    strMsg:string;
   sParams: TStringStream;
   s,str,CookieStr:string;
   snc:string;
begin
memo1.clear;
s := 'http://px.zznews.gov.cn/xxxdzc.php?group=28';
if CanGetIECookie(s, str) then
begin
    CookieStr := 'Cookie: ' + str;
    idHttp1.Request.CustomHeaders.Text := CookieStr;
end else
begin
    ShowMessage('没有发现本地Cookie,请从Web页面登陆一次。');
    Exit;
end;
  sParams := TStringStream.create('');
  IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
  idhttp1.Request.Referer:='http://px.zznews.gov.cn/xxxdzc.php?group=28C:\Program Files\Microsoft\soft1\Internet  Explorar';
  try
  sParams.WriteString('nt=12996417340&user=&vid=|BC9C33DQkLDAAMAA8ADQBdDg5bDgkBCAwKCgwOCQ0ACloO&randcode='+trim(edit1.Text)+'&time=1348487906531&_=') ;
   /// idhttp1.request.customheaders.text:='cookie:'+'dbsessionId=c89aa4d090825f47998eb6bd1fdeb8dc; cnzz_a2523094=0; sin2523094=; rtime=0; ltime=1323581940578; cnzz_eid=14226567-1323577009-';
    strMsg:=IdHTTP1.post('http://px.zznews.gov.cn/ajax.php',sParams)  ;
    memo1.Text:=UTF8ToAnsi(strmsg);
  finally
    sParams.Free ;
  end;
 end;
procedure TForm1.Button2Click(Sender: TObject);
begin
memo1.Clear;
edit1.Clear;
webbrowser1.Navigate('http://px.zznews.gov.cn/includes/rand_func.php?rc=42107');
edit1.SetFocus;
end;感谢