Q&A

  • url이 살았는지 죽었는지 알아내는 방법이 궁금합니다.
질문 그대로 입니다.



url을 주어서 그 url이 살았는지 죽었는지 알고 싶습니다.



한수 가르쳐 주세염.



그럼 ^^;



i believe i can fly~~

2  COMMENTS
  • Profile
    구창민 2001.09.15 05:30
    irookie wrote:

    > 질문 그대로 입니다.

    >

    > url을 주어서 그 url이 살았는지 죽었는지 알고 싶습니다.

    >

    > 한수 가르쳐 주세염.

    >

    > 그럼 ^^;

    >

    > i believe i can fly~~





    안녕하세요~~ 구창민입니다.



    아래는 URL이 유효한지 검사하는 예제입니다.



    참고하시고, 항상 즐거운 프로그래밍 하시길~~~~~



    Checking URL Sample

    // Author: Greg Holowatinc (MetZ = nwillams@telusplanet.net)

    // Co-Author: David Turner (Leapix = leapix@dal.net)



    unit Unit1;



    interface



    uses

    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

    StdCtrls;



    type

    TForm1 = class(TForm)

    Edit1: TEdit;

    Button1: TButton;

    procedure Button1Click(Sender: TObject);

    private

    { Private declarations }

    public

    { Public declarations }

    end;



    var

    Form1: TForm1;



    implementation

    {$R *.DFM}



    function IsUrl(S: string): Boolean;

    const

    // First off we set a few characters that cannot

    // exist in any given case.

    // These can be modified right here without penalty.

    BADCHARS = ';*<>{}[]|()^!';

    var

    //We then set a few integers as our variables - mostly counter stuff.

    p, x, c, count, i: Integer;

    begin

    //First thing we do is go the negative way.

    // so set result to false

    Result := False;



    //The length has to be greater than 5 and stuff

    // like www.myhouse. or www..hello cannot

    //exist - so we rule out these right here.

    if (Length(S) > 5) and (S[Length(S)] <> '.') and (Pos(S, '..') = 0) then

    begin

    //The first initial test has passed. Now we sort through

    //the bad chars using a counter.

    for i := Length(BADCHARS) downto 1 do

    if Pos(BADCHARS[i], S) > 0 then

    System.Exit;



    //Anything below CHR33 and above CHR126 is crap when it comes to internet links.

    for i := 1 to Length(S) do

    if (Ord(S[i]) < 33) or (Ord(S[i]) > 126) then

    System.Exit;



    //Ok, first we look at the domain names. Make sure they fit the minimal template.

    if ((Pos('www.',LowerCase(S)) = 1) and

    (Pos('.', Copy(S, 5, Length(s))) > 0) and

    (Length(S) > 7)) or

    //A news thing is very similar, so we include it in the OR statement.

    ((Pos('news:', LowerCase(S)) = 1) and

    (Length(S) > 7) and

    (Pos('.', Copy(S, 5, Length(S))) > 0))

    then

    begin

    //Naturally, if all goes well and the test is passed, we end

    //the seek right there.

    Result := True;

    System.Exit;

    end

    //This is the mail section - and it will recognize any email addresses found.

    else if ((Pos('mailto:', LowerCase(S)) = 1) and (Length(S) > 12) and

    (Pos('@', S) > 8) and (Pos('.', S) > 10) and

    (Pos('.', S) > (Pos('@', S) +1))) or

    ((Length(S) > 6) and (Pos('@', S) > 1) and (Pos('.', S) > 4) and

    (Pos('.', S) > (Pos('@', S) +1)))

    then

    begin

    Result := True;

    System.Exit;

    end

    //An extention of all www. stuff is here with the browser headers included.

    else if ((Pos('http://', LowerCase(S)) = 1) and

    (Length(S) > 10) and

    (Pos('.', S) > 8)) or

    ((Pos('ftp://', LowerCase(S)) = 1) and

    (Length(S) > 9) and (Pos('.', S) > 7))

    then

    begin

    Result := True;

    System.Exit;

    end

    else

    begin

    // So we have passed all of the word types. Now its time to see

    // if the thing contains numbers in such format as a numeric ip would be.

    Result := True;

    for Count := 1 to 4 do

    begin

    p := Pos('.',S) - 1;

    if p < 0 then

    p := Length(S);

    Val(Copy(S, 1, p), x, c);

    if ((c <> 0) or (x < 0) or (x > 255) or (p>3)) then

    begin

    Result := False;

    Break;

    end;

    Delete(S, 1, p + 1);

    end;

    if (S <> '') then

    Result := False;

    end;

    end;

    end;



    procedure TForm1.Button1Click(Sender: TObject);

    begin

    if not IsURL(Edit1.Text) then

    Showmessage('유효하지 않은 URL 입니다');



    (* Checking URL Sample

    1. www.leapware.com

    2. http://www.leapware.com

    3. nwillams@telusplanet.net

    4. mailto:nwillams@telusplanet.net

    3. news:alt.why.do.i.bother

    4. ftp:://ftp.microsoft.com

    5. 192.168.0.1

    *)

    end;



    end.









  • Profile
    stoney 2001.09.15 02:58
    해당 URL로 Ping 때려보시면 되죠.. ^^



    irookie wrote:

    > 질문 그대로 입니다.

    >

    > url을 주어서 그 url이 살았는지 죽었는지 알고 싶습니다.

    >

    > 한수 가르쳐 주세염.

    >

    > 그럼 ^^;

    >

    > i believe i can fly~~