Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

testing if a URL exists

Status
Not open for further replies.

EricE

IS-IT--Management
Oct 6, 2000
17
0
0
US
I am looking for a way to test if a URL exists. For example, I want to know if works or it doesn't. Is there a way? Eric
 
hi eric

u can treat a url as a file and try to open it.

so try something like this





if($hnl = @fopen("
echo "URL exists" ;

else

echo "URL doesnot exist" ;



hope that will help u

cheers

spookie
 

just ignore the semicolon after the url.i dont know how it appeared there :)

cheers

spookie
 
I tried it spookie...seems to work great for one thing but not for the other. The other is testing to see if a live mms://url.com/show microsoft streaming media stream is active. The fopen doesn't seem to work for that.

ty, Eric Eric
 
Hello Eric,

Once I've written an application that checked if a url existed. The primary goal was getting the result from a request to a url.

When the site didn't exist you would get a html page returned with a HTTP 404 error as title. So when you read the html source and search if <title>HTTP 404 Not found</title> exist within this source you will know if the site exists or not(or if it's in the eare or not).

I hope it will help,

Charl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top