CSDN 文件下载工具。 免登录,免扣分。
感谢万一前辈,感谢土司论坛。
CSDN 文件下载工具。 免登录,免扣分。
里面所谓的ID ,是指下载页url后面的那串数字。
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellAPI; type TForm1 = class(TForm) Label1: TLabel; Edit1: TEdit; Button1: TButton; Memo1: TMemo; Label2: TLabel; Button2: TButton; Label3: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses MsXML;
{ Code By Noevil -- Thank you! }
{ 分割字符串的函数, 其实是个过程 } procedure Split(const str: string; const c: Char; var List: TStrings); begin List.Clear; List.Delimiter := c; List.DelimitedText := str; end; procedure TForm1.Button1Click(Sender: TObject); var SoftUrl: IXMLHTTPRequest; Url: String; Temp: String; List: TStrings; begin { 取得ID } Url := 'http://download.csdn.net/index.php/rest/source/getsourceinfo/' + Edit1.Text; { 利用bug } SoftUrl := CoXMLHTTP.Create; // 较早的版本或许是 SoftUrl := CoXMLHTTPRequest.Create; SoftUrl.open('Get', Url, False, EmptyParam, EmptyParam); SoftUrl.send(EmptyParam); { 凶猛的替换 } Temp := StringReplace(SoftUrl.responseText, '"', '', [rfReplaceAll]); Temp := StringReplace(Temp, '\', '', [rfReplaceAll]); Temp := StringReplace(Temp, '{', '', [rfReplaceAll]); Temp := StringReplace(Temp, '}', '', [rfReplaceAll]); Temp := StringReplace(Temp, 'url:', ';', [rfReplaceAll]); Temp := StringReplace(Temp, ' ', '', [rfReplaceAll]); Temp := StringReplace(Temp, 'http#', 'http:', [rfReplaceAll]); Memo1.Text := Temp; { 提取下载地址链接 } List := TStringList.Create; Split(Memo1.Text, ';', List); Memo1.Text := List[1]; List.Free; end; procedure TForm1.Button2Click(Sender: TObject); var SoftUrl: IXMLHTTPRequest; Url: String; Temp: String; List: TStrings; begin { 取得ID } Url := 'http://download.csdn.net/index.php/rest/source/getsourceinfo/' + Edit1.Text; { 利用bug } SoftUrl := CoXMLHTTP.Create; // 较早的版本或许是 SoftUrl := CoXMLHTTPRequest.Create; SoftUrl.open('Get', Url, False, EmptyParam, EmptyParam); SoftUrl.send(EmptyParam); { 凶猛的替换 } Temp := StringReplace(SoftUrl.responseText, '"', '', [rfReplaceAll]); Temp := StringReplace(Temp, '\', '', [rfReplaceAll]); Temp := StringReplace(Temp, '{', '', [rfReplaceAll]); Temp := StringReplace(Temp, '}', '', [rfReplaceAll]); Temp := StringReplace(Temp, 'url:', ';', [rfReplaceAll]); Temp := StringReplace(Temp, ' ', '', [rfReplaceAll]); Temp := StringReplace(Temp, 'http#', 'http:', [rfReplaceAll]); Memo1.Text := Temp; { 提取下载地址链接 } List := TStringList.Create; Split(Memo1.Text, ';', List); Memo1.Text := List[1]; List.Free; ShellExecute(Handle, 'open', 'IExplore.EXE', PWideChar(Memo1.Text), nil, SW_SHOWNORMAL); end; end.