当我尝试登录Craigslist时,为什么会收到登录页面?

问题描述:

我正在尝试使用Delphi 2010和Indy 10的最新版本登录Craigslist,并检索我的帐户页面(以便收集我所有帖子的列表)。当我尝试登录Craigslist时,为什么会收到登录页面?

但是,当我发布登录详细信息时,the returned HTMLthat of the login page,而我期望得到my account page listing my postings

这里是我的最新代码:

function TfrmMain.Login: string; 
var 
    IdHTTP: TIdHTTP; 
    Request: TStringList; 
    Response: TMemoryStream; 
    SSLHandler: TIdSSLIOHandlerSocketOpenSSL; 
begin 
    Result := ''; 
    try 
    Response := TMemoryStream.Create; 
    try 
     Request := TStringList.Create; 
     try 
     Request.Add('op=login'); 
     Request.Add('redirect=http://www.craigslist.org/'); 
     Request.Add('login=' + edtEmail.Text); 
     Request.Add('password=' + edtPassword.Text); 
     IdHTTP := TIdHTTP.Create; 
     try 
      SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil); 
      try 
      SSLHandler.SSLOptions.Method := sslvSSLv3; 
      SSLHandler.SSLOptions.Mode := sslmUnassigned; 

      IdHTTP.IOHandler := SSLHandler; 
      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 
      SSLHandler.Free; 
      end; 
     finally 
      IdHTTP.Free; 
     end; 
     finally 
     Request.Free; 
     end; 
    finally 
     Response.Free; 
    end; 
    except 
    on E: Exception do 
     ShowMessage(E.Message); 
    end; 
end; 

我已经通过调试,由于他们在请求参数传递的电子邮件地址和密码是正确的价值观得到证实,那么为什么我没有拿到的页面我期待?

根据您收到的HTML,登录字段的名称是inputEmailHandle,而不是login。同样,密码字段是,而不是password。还有一些其他字段可省略,包括step,rtrp。我在表单中看不到opredirect字段。

换句话说,这里显示的代码不是登录到Craigslist的代码;它的地址在code for logging in to Filestrum之间变化,而不考虑周围代码的重要性。