Computing.Net > Forums > Web Development > How to check external URL exists

How to check external URL exists

Reply to Message Icon

Original Message
Name: deadlydog
Date: March 22, 2005 at 12:19:06 Pacific
Subject: How to check external URL exists
OS: Mandrake 10.1
CPU/Ram: P233
Comment:

I want to be able to check if a URL is live or not. Basically I want to make a function I can call and supply the URL, and it checks to see if the URL is currently up and running or not. I'm using html, javascript, and php. Currently I'm just doing this with php:

function URLIsLive($URL)
{
return fopen($URL, 'r');
}

It does work for what I need, but it is painfully slow, whether the websites are up or not. It takes about 15 seconds to load the page, which sux. Is there a faster way to do this?

Thanks. Dan


Report Offensive Message For Removal

Response Number 1
Name: FBI Agent
Date: March 23, 2005 at 21:05:04 Pacific
Subject: How to check external URL exists
Reply: (edit)

PHPs file_exists()

if you need any help on it just IM me on AIM or just repost it on here and i'll give you an example of a complete PHP file (assuming you dont know much PHP)

FBI Agent

AIM: EliteAssassin187


Report Offensive Follow Up For Removal

Response Number 2
Name: FishMonger
Date: March 24, 2005 at 08:28:33 Pacific
Subject: How to check external URL exists
Reply: (edit)

http://us4.php.net/manual/en/function.get-headers.php


Report Offensive Follow Up For Removal

Response Number 3
Name: deadlydog
Date: March 24, 2005 at 08:59:33 Pacific
Subject: How to check external URL exists
Reply: (edit)

Well, I tried using file_exists($URL); but that just returns false for everything, so I can't use that. And I was looking at the get_headers() function, but it's only available in PHP 5 and I'm still using 4.3.10. Any other suggestions? I might end up upgrading to PHP 5, I just hope I don't run into any problems and that everything will still work correctly.

Dan


Report Offensive Follow Up For Removal

Response Number 4
Name: FishMonger
Date: March 24, 2005 at 20:04:15 Pacific
Subject: How to check external URL exists
Reply: (edit)

Personally, I prefer to usr Perl, I only use PHP when my boss insists, PHP is 10yrs behind Perl in its development.

Here's another PHP function that is compatible with PHP4.

http://us3.php.net/manual/en/function.get-meta-tags.php


Report Offensive Follow Up For Removal

Response Number 5
Name: FishMonger
Date: March 24, 2005 at 21:31:53 Pacific
Subject: How to check external URL exists
Reply: (edit)

Here's another function that would be than the get_meta_tags and is compatible with PHP4.

http://us3.php.net/manual/en/function.header.php


Report Offensive Follow Up For Removal


Response Number 6
Name: FishMonger
Date: March 24, 2005 at 21:34:39 Pacific
Subject: How to check external URL exists
Reply: (edit)

Oops, forget that last one, it's for sending not retrieving the headers.


Report Offensive Follow Up For Removal

Response Number 7
Name: deadlydog
Date: March 30, 2005 at 10:58:28 Pacific
Subject: How to check external URL exists
Reply: (edit)

Well, I tried using the get_meta_tags() function, but that took even longer than the fopen(), and it returned false for some sites that were up and running. Any other ideas? Thanks.

Dan

-- God is my favorite fictional character


Report Offensive Follow Up For Removal

Response Number 8
Name: deadlydog
Date: March 30, 2005 at 11:00:01 Pacific
Subject: How to check external URL exists
Reply: (edit)

I'm open to trying other things to. If I was to try and do this with Perl, what would I need to do?

-- God is my favorite fictional character


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: How to check external URL exists

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software