Log in to website from Delphi

后端 未结 1 462
感动是毒
感动是毒 2020-12-09 05:59

I would ask if someone was kind enough to explain to me how to login at webpage from Delphi app. All the examples I\'ve found here have proved useless to me or I\'m doing so

相关标签:
1条回答
  • 2020-12-09 06:12

    Try something like this:

    function 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://www.filestrum.com');
            Request.Add('login=example');
            Request.Add('password=example');
            IdHTTP := TIdHTTP.Create;
            try
              IdHTTP.AllowCookies := True;
              IdHTTP.HandleRedirects := True;
              IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
              IdHTTP.Post('http://www.filestrum.com/', Request, Response);
              Result := IdHTTP.Get('http://www.filestrum.com/?op=my_account');    
            finally
              IdHTTP.Free;
            end;
          finally
            Request.Free;
          end;
        finally
          Response.Free;
        end;
      except
        on E: Exception do
          ShowMessage(E.Message);
      end;
    end;
    
    0 讨论(0)
提交回复
热议问题