I'm currently using

function ValidateURL(const URL: string): boolean;
var
grab: THTTPSend;
sl: TStringList;
Cntr: integer;
Location: string;
AddSlash: string;
begin
if URL = '' then begin
Result := False;
Exit;
end;
sl := TStringList.Create;
grab := THTTPSend.Create;
grab.Timeout := 2000;
sl.Text := URL;
Result := True;
try
for Cntr := 0 to sl.Count - 1 do begin
if IsURL(sl[Cntr]) then begin
if grab.HTTPMethod('GET', sl[Cntr]) then begin
if (grab.ResultCode div 100) <> 2 then begin
if grab.ResultCode = 302 then begin
Location := Copy(grab.Headers.Text, Pos('location:', 
LowerCase(grab.Headers.Text)) + 9, MaxInt);
if 0 <> Pos('opendns.com', LowerCase(Location)) then begin
Result := False;
Break;
end else begin
Location := LowerCase(Copy(Location, 1, Pos(#13, Location) - 1));
if 0 <> Pos('?', Location) then begin
if URL[Length(URL)] = '/' then AddSlash := '/' else AddSlash := '';
if LowerCase(URL) = Copy(Location, Pos('?url=', Location) + 5, MaxInt) + 
AddSlash then begin
Result := False;
Break;
end;
end;
end;
// have to assume its OK cos I can't do much else
end else begin
Result := False;
Break;
end;
end;
grab.Clear;
end else begin
Result := False;
Break;
end;
end else begin
Result := False;
Break;
end;
end;
finally
grab.Free;
sl.Free;
end;
end;

to see if a website exists. Can anyone suggest a better approach?


Roy Lambert

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to