如何判断这中 URL http://www.baidu.com/baidu.rar 是不是有效
下面这个函数 是我写的 如果参数是 http://www.baidu.com 这个函数有效 但是参数是http://www.baidu.com/baidu.rar的时候这个函数 就没了效果谁能告诉我应该怎么改
function Get(URL: string): boolean;
var
IDHTTP: TIDHttp;
ss: String;
begin
Result:= False;
IDHTTP:= TIDHTTP.Create(nil);
try
try
idhttp.HandleRedirects:= true; //必须支持重定向否则可能出错9C ?$M G7Z y {0K M o
idhttp.ReadTimeout:= 30000; //超过这个时间则不再访问
ss:= IDHTTP.Get(URL);
if IDHTTP.ResponseCode=200 then
Result :=true;
except
end;
finally
IDHTTP.Free;
end;
end;
function Get(URL: string): boolean;
var
IDHTTP: TIDHttp;
ss: String;
begin
Result:= False;
IDHTTP:= TIDHTTP.Create(nil);
try
try
idhttp.HandleRedirects:= true; //必须支持重定向否则可能出错9C ?$M G7Z y {0K M o
idhttp.ReadTimeout:= 30000; //超过这个时间则不再访问
ss:= IDHTTP.Get(URL);
if IDHTTP.ResponseCode=200 then
Result :=true;
except
end;
finally
IDHTTP.Free;
end;
end;
不要 看报的是http 404 ,http 302,这样的 ~再根据错的不同的信息进行处理 这样的是判断网页 就别说了 直接给个思路
下面这个函数 是我写的 如果参数是 http://www.baidu.com 这个函数有效 但是参数是http://www.baidu.com/baidu.rar的时候这个函数 就没了效果谁能告诉我应该怎么改
function Get(URL: string): boolean;
var
IDHTTP: TIDHttp;
ss: String;
begin
Result:= False;
IDHTTP:= TIDHTTP.Create(nil);
try
try
idhttp.HandleRedirects:= true; //必须支持重定向否则可能出错9C ?$M G7Z y {0K M o
idhttp.ReadTimeout:= 30000; //超过这个时间则不再访问
ss:= IDHTTP.Get(URL);
if IDHTTP.ResponseCode=200 then
Result :=true;
except
end;
finally
IDHTTP.Free;
end;
end;
function Get(URL: string): boolean;
var
IDHTTP: TIDHttp;
ss: String;
begin
Result:= False;
IDHTTP:= TIDHTTP.Create(nil);
try
try
idhttp.HandleRedirects:= true; //必须支持重定向否则可能出错9C ?$M G7Z y {0K M o
idhttp.ReadTimeout:= 30000; //超过这个时间则不再访问
ss:= IDHTTP.Get(URL);
if IDHTTP.ResponseCode=200 then
Result :=true;
except
end;
finally
IDHTTP.Free;
end;
end;
不要 看报的是http 404 ,http 302,这样的 ~再根据错的不同的信息进行处理 这样的是判断网页 就别说了 直接给个思路
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货