delphi之伪造referer下载文件

菜鸟编程 十五楼的鸟儿 1229浏览 0评论
今天去了某经常去下载文件的地方,居然不能通过迅雷下载,简单的测试了下发现是检查了referer,所以花点时间做了下面的这个东西。
[code=delphi]
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, IdAntiFreezeBase, IdAntiFreeze, StdCtrls;

type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Button1: TButton;
IdAntiFreeze1: TIdAntiFreeze;
Label1: TLabel;
Memo1: TMemo;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
i:Integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
MyStream:TMemoryStream;
downloadurl,datex:string;
begin
while i<230 do //文本只有229行哈~~
begin
downloadurl:=memo1.lines[i-1];//取出memo中的数值,memo1.lines[i-1]是第i行
IdAntiFreeze1.OnlyWhenIdle:=False;//设置使程序有反应.
MyStream:=TMemoryStream.Create;
IdHTTP1.Request.Referer:='http://www.nobird.org/';//这里设置的referer的地址。
datex:= FormatDateTime('yyyymmddhhnnss',now());//时间命名,免得重复
try
Id