SCAR Code:
type
TImageCollection = array of record
imgType, imgName: string;
end;
var
a, b, c, d, e, h, tpc, msTotal: Integer;
Path2Dl: string;
TSA, ft: TStringArray;
TIA: TIntegerArray;
f: Boolean;
pc: TImageCollection;
procedure Download(image: string);
var
ps: string;
iFile, i, tmr: Integer;
iD: Boolean;
begin
tmr:= GetSystemTime;
for i:= 0 to h do
try
ps:= GetPage(Copy(('http://www.runescapetop.com/up/images/' + image + ft[i]), Pos('http://', ('http://www.runescapetop.com/up/images/' + image + ft[i])), Length(('http://www.runescapetop.com/up/images/' + image + ft[i])) + 1));
if(ps <> '')then
begin
iFile:= RewriteFile((Path2Dl + 'img' + IntToStr(tpc) + '_[' + image + ']' + ft[i]), False);
iD:= WriteFileString(iFile, ps);
CloseFile(iFile);
if(iD)then
begin
msTotal:= (msTotal + GetSystemTime - tmr);
TIA[i]:= (TIA[i] + 1);
pc[tpc].imgType:= ft[i];
pc[tpc].imgName:= image;
if((tpc + 1) > 1)then
Status(IntToStr(tpc + 1) + ' images downloaded at average speed of ' + IntToStr(Round(msTotal / (tpc + 1))) + ' ms. per img!')
else
Status(IntToStr(tpc + 1) + ' image downloaded at speed of ' + IntToStr(msTotal) + 'ms.');
Inc(tpc);
Break;
end;
end else
ClearDebug;
except
end;
f:= ((i > (h + 1))or(IsFKeyDown(12)));
end;
procedure CreateDirs;
var
i: Integer;
begin
SetArrayLength(pc, 2000000);
a:= 1;
for i:= 0 to 1999999 do
begin
e:= (e + 1);
if(e = 15)then
begin
e:= 0;
d:= (d + 1);
if(d = 15)then
begin
d:= 0;
c:= (c + 1);
if(c = 15)then
begin
c:= 0;
b:= (b + 1);
if(b = 15)then
begin
b:= 0;
a:= (a + 1);
end;
end;
end;
end;
Download(TSA[a] + TSA[b] + TSA[c] + TSA[d] + TSA[e]);
if(f)then
Break;
end;
SetArrayLength(pc, tpc);
ClearDebug;
WriteLn(IntToStr(tpc) + ' images:');
for i:= 0 to (tpc - 1) do
WriteLn('Image[' + IntToStr(i) + '] - name: ' + pc[i].imgName + ', type: ' + pc[i].imgType);
SetArrayLength(pc, 0);
end;
begin
ClearDebug;
ClearReport;
TSA:= ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
ft:= ['.png', '.jpg', '.bmp', '.tif', '.gif'];
h:= High(ft);
SetArrayLength(TIA, (h + 1));
Path2Dl:= (ScriptPath + 'images\');
CreateDirs;
SetArrayLength(TSA, 0);
SetArrayLength(ft, 0);
SetArrayLength(TIA, 0);
end.