CBL Checker(Delphi)

Posts 1–4 of 4 · Page 1 of 1
CBL Checker(Delphi)
I have a few people pm about the CBL checker program, so here it is

Code:
implementation

{$R *.dfm}

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
    Button1.Click;
end;

Function Extract(Const sString, Stat: String): String;
Var
  sTemp: String;
begin
  Result := '';
  sTemp := TRegEx.Match(sString, '(?si)<td class="item">' + Stat +
    '</td>.*?</td>').Value;
  sTemp := TRegEx.Match(sTemp, '(?si)value">.*?</td>').Value;
  Result := Copy(sTemp, 8, Length(sTemp) - 12);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  IdHTTP1.Free;
end;

Procedure TForm1.ParseStats(Const sString: String);
var
  sTemp: String;
begin
  sTemp := sString;
  Delete(sTemp, 1, pos('<table class="plrStats"', sTemp));
  lblKills.Caption := Extract(sTemp, 'Kills');
  lblDeaths.Caption := Extract(sTemp, 'Deaths');
  lblKDR.Caption := Extract(sTemp, 'KDR');
  lblEXP.Caption := Extract(sTemp, 'Experience');
  lblRank.Caption := Extract(sTemp, 'Ranking');
  lblStreak.Caption := Extract(sTemp, 'Streak');
  lblGP.Caption := Extract(sTemp, 'GP');
  lblHS.Caption := Extract(sTemp, 'HS');
  lblEnlisted.Caption := Extract(sTemp, 'Enlisted');

end;

Procedure TForm1.GetStatus(const UserName: String);
var
  sString: String;
  msPicture: TStream;
  pngPicture: TPngImage;
begin
  msPicture := TMemoryStream.Create;
  pngPicture := TPngImage.Create;
  try
    sString := IdHTTP1.Get('http://www.thecaconline.net/cbl/player/' +
      Pchar(UserName) + '.html');
    if ((AnsiContainsStr(sString, 'dirty.png')) or
      (AnsiContainsStr(sString, 'clean.png'))) then
    begin
      if AnsiContainsStr(sString, 'clean.png') then
        imgStatus.Picture := Image2.Picture
      else
        imgStatus.Picture := Image1.Picture;;

      IdHTTP1.Get
        ('http://combat.nexon.net/Avatar/MyAvatar.srf?GameName=CombatArms&CharacterID='
        + Pchar(UserName), msPicture);
      msPicture.Seek(0, soFromBeginning);
      pngPicture.LoadFromStream(msPicture);
      imgUser.Picture.Assign(pngPicture);
      ParseStats(sString);
    end
    else
      Showmessage('User Not Found!!!');

  finally
    msPicture.Free;
    pngPicture.Free;
    lblSearching.Visible := False;
    IdHTTP1.Disconnect;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  lblSearching.Visible := True;
  Application.ProcessMessages;
  GetStatus(Edit1.Text);
end;

end.
as you can see I did'nt spend much time on making this, about 30 minutes all up and 20 minutes of that was working out a good extraction function it uses the Indy component to connect....
nice
i made a similar thing using vb
Nce, this ++ advanced... nce job sir
You made that in about half hour? Nice mang.
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us