Hoje eu vi uma postagem no S8S8. Um script de shell, idioma C, C ++, VBS, PHP, Perl, Java e C#, é um capricho. , mas depois de ler algumas fotos, todas elas não eram adequadas para crianças.
Código completo do programa:
// A escrita é relativamente difícil, mas pode basicamente perceber a função de download, por isso não posso controlar muito.
unidade getmm;
interface
usos
Janelas, mensagens, sysutils, variantes, classes, gráficos, controles, formulários,
Diálogos, stdctrls, iDbaseComponent, IdComponent, IDTCPConnection,
IDTCPCLIENT, IDHTTP;
const
Url = 'http: //www.sergeaura.net/tgp/';
Offi = 192;
Offj = 16;
Girlpic = 'C:/Girlpic/';
// Classe de thread
tipo
Tgetmm = classe (tthread)
Protegido
Fmmurl: string;
FdestPath: string;
Fsubj: string;
procedimento executar; substituir;
público
Construtor Create (mmurl, DestPath, Subj: String);
fim;
tipo
Tform1 = classe (tform)
Button1: tbutton;
Button2: tbutton;
Memorando1: TMemo;
Idhttp1: tidhttp;
Caixa de seleção1: tcheckbox;
Procedimento Button1Click (remetente: Tobject);
Procedimento Button2Click (remetente: Tobject);
Privado
{Declarações privadas}
Rgetmm: tthread;
Procedimento getMmThread (mmurl, DestPath, Subj: String);
público
{Declarações públicas}
fim;
var
Form1: TForm1;
Implementação
{$ R *.dfm}
// Processo de download
procedimento TForm1.Button1Click (remetente: TOBJECT);
var
I, J: Inteiro;
Subi, Subj, Cururl, DestPath: String;
STRM: tMemorystream;
Começar
Memo1.Lines.clear;
// Crie um diretório
Se não o DirectoryExists (feminino) então
Mkdir (feminino);
tentar
strm: = tmemorystream.create;
para i: = 1 para offi fazer
Começar
para j: = 1 a offj fazer
Começar
se (i <10) então
Subi: = '00'+inttostr (i)
senão se (i> 9) e (i <100) então
Subi: = '0'+inttostr (i)
else subi: = inttostr (i);
se (j> 9) então
Subj: = inttostr (j)
else subj: = '0'+inttostr (j);
Cururl: = url+subi+'/imagens/';
DestPath: = Girlpic+Subi+'/';
Se não o DirectoryExists (DestPath), então
Forcedirectories (Destpath);
// Use threads, a velocidade pode ser aumentada em mais de n vezes
Se a caixa de seleção1.Charquei, então
Começar
GetMmthread (cururl, DestPath, SubJ);
sono (500);
fim mais
// nenhum fio é usado
Começar
tentar
strm.clear;
Idhttp1.get (cururl+subj+'. Jpg', strm);
strm.Savetofile (DestPath+Subj+'. JPG');
Memor1.lines.add (cururl+'download ok!');
strm.clear;
Idhttp1.get (cururl+'tn _'+subj+'. Jpg', strm);
strm.Savetofile (DestPath+'TN _'+Subj+'. JPG');
Memor1.lines.add (cururl+'download ok!');
exceto
Memor1.lines.add (Cururl+'Erro de download!');
fim;
fim;
fim;
fim;
Memando1.lines.add ('tudo ok!');
Finalmente
strm.Free;
fim;
fim;
procedimento TForm1.Button2Click (remetente: TOBJECT);
Começar
Fechar;
fim;
{Tgetmm}
construtor tgetmm.create (mmurl, DestPath, subj: string);
Começar
Fmmurl: = mmurl;
FDESTPATH: = DestPath;
Fsubj: = subj;
Criar herdado (false);
fim;
procedimento tgetmm.execute;
var
STRM: tMemorystream;
Idgetmm: tidhttp;
Destfile: string;
Começar
tentar
strm: = tmemorystream.create;
IDgetmm: = tidhttp.create (nil);
tentar
Destfile: = fdestPath+fsubj+'. Jpg';
Se não o FileExists (Destfile), então
Começar
strm.clear;
IDgetMm.get (fmmurl+fsubj+'. Jpg', strm);
strm.Savetofile (Destfile);
fim;
Destfile: = fdestPath+'tn _'+fsubj+'. Jpg';
Se não o FileExists (Destfile), então
Começar
strm.clear;
IDgetMm.get (fmmurl+'tn _'+fsubj+'. Jpg', strm);
strm.Savetofile (Destfile);
fim;
exceto
fim;
Finalmente
strm.Free;
IdgetMm.Free;
fim;
fim;
procedimento tForm1.getMmThread (mmurl, DestPath, SubJ: String);
Começar
Rgetmm: = tgetmm.create (mmurl, DestPath, subj);
fim;
fim.