如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
用Delphi实现整个网站图片的极速下载//写的比较粗糙,但基本能实现下载功能,管不了那么多了。unitGetMM;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls,IdBaseComponent,IdComponent,IdTCPConnection,IdTCPClient,IdHTTP;constUrl=\’http://www.sergeaura.net/TGP/\’;//下载图片的网站地址OffI=192;//目录个数OffJ=16;//每个目录下的最大图片数girlPic=\’C:\\girlPic\\\’;//保存在本地的路径//线程类typeTGetMM=class(TThread)protectedFMMUrl:string;FDestPath:string;FSubJ:string;procedureExecute;override;publicconstructorCreate(MMUrl,DestPath,SubJ:string);end;typeTForm1=class(TForm)Button1:TButton;Button2:TButton;Memo1:TMemo;IdHTTP1:TIdHTTP;CheckBox1:TCheckBox;procedureButton1Click(Sender:TObject);procedureButton2Click(Sender:TObject);private{Privatedeclarations}RGetMM:TThread;procedureGetMMThread(MMUrl,DestPath,SubJ:string);public{Publicdeclarations}end;varForm1:TForm1;implementation{$R*.dfm}//下载过程procedureTForm1.Button1Click(Sender:TObject);vari,j:integer;SubI,SubJ,CurUrl,DestPath:string;strm:TMemoryStream;beginmemo1.Lines.Clear;//建立目录ifnotDirectoryExists(girlPic)thenMkDir(girlPic);trystrm:=TMemoryStream.Create;forI:=1toOffIdobeginforj:=1toOffJdobeginif(i<10)thenSubI:=\’00\’+IntToStr(i)elseif(i>9)and(i<100)thenSubI:=\’0\’+inttostr(i)elseSubI:=inttostr(i);if(j>9)thenSubJ:=inttostr(j)elseSubJ:=\’0\’+inttostr(j);CurUrl:=Url+SubI+\’/images/\’;DestPath:=girlPic+SubI+\’\\\’;ifnotDirectoryExists(DestPath)thenForceDirectories(DestPath);//使用线程,速度能提高N倍以上ifCheckBox1.CheckedthenbeginGetMMThread(CurUrl,DestPath,SubJ);sleep(500);endelse//不使用线程begintrystrm.Clear;IdHTTP1.Get(CurUrl+SubJ+\’.jpg\’,strm);strm.SaveToFile(DestPath+SubJ+\’.jpg\’);Memo1.Lines.Add(CurUrl+\’DownloadOK!\’);strm.Clear;IdHTTP1.Get(CurUrl+\’tn_\’+SubJ+\’.jpg\’,strm);strm.SaveToFile(DestPath+\’tn_\’+SubJ+\’.jpg\’);Memo1.Lines.Add(CurUrl+\’DownloadOK!\’);exceptMemo1.Lines.Add(CurUrl+\’DownloadError!\’);end;end;end;end;Memo1.Lines.Add(\’AllOK!\’);finallystrm.Free;end;end;procedureTForm1.Button2Click(Sender:TObject);beginClose;end;{TGetMM}constructor