0

我正在尝试使用 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);

谢谢

4

1 回答 1

3

请参阅(Indy) TIdHTTP EIdSocketError Socket Error # 0 下载文件时的异常和评论中的建议。看来您应该升级到更新版本的 Indy。

于 2013-03-25T16:29:54.547 回答