使用Delphi和Indy以及SSL登录craigslist以检索帐户页面

时间:2013-03-25 15:02:08

标签: delphi http delphi-2010 indy

我正在尝试使用Delphi登录craigslist,并检索我的帐户页面(为了收集我所有帖子的列表)

但是,我似乎无法登录工作,我做错了什么?

function TfrmMain.Login: string;
var
  IdHTTP: TIdHTTP;
  Request: TStringList;
  Response: TMemoryStream;
begin
  Result := '';
  try
    Response := TMemoryStream.Create;
    try
      Request := TStringList.Create;
      try
        Request.Add('op=login');
        Request.Add('redirect=http://newyork.craigslist.org/');
        Request.Add('login=' + myEmail);
        Request.Add('password=' + myPassword);
        IdHTTP := TIdHTTP.Create;
        try
          IdHTTP.AllowCookies := True;
          IdHTTP.HandleRedirects := True;
          IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
          IdHTTP.Post('https://accounts.craigslist.org/login', Request, Response);
          Result := IdHTTP.Get('https://accounts.craigslist.org/');
        finally
          IdHTTP.Free;
        end;
      finally
        Request.Free;
      end;
    finally
      Response.Free;
    end;
  except
    on E: Exception do
      ShowMessage(E.Message);
  end;
end;

我在行上获得了一个异常类EIdIOHandlerPropInvalid,消息“IOHandler值无效”:

IdHTTP.Post('https://accounts.craigslist.org/login', Request, Response);

感谢

1 个答案:

答案 0 :(得分:3)

请参阅(Indy) TIdHTTP EIdSocketError Socket Error # 0 exceptions when downloading files以及评论中的建议。看起来您应该升级到更新版本的Indy。