Alex Rivera | Logout

How do I check for valid (not dead) links programmatically using PHP?

Asked 2008-10-28T19:25:04.887
15

Given a list of urls, I would like to check that each url:

  • Returns a 200 OK status code
  • Returns a response within X amount of time

The end goal is a system that is capable of flagging urls as potentially broken so that an administrator can review them.

The script will be written in PHP and will most likely run on a daily basis via cron.

The script will be processing approximately 1000 urls at a go.

Question has two parts:

  • Are there any bigtime gotchas with an operation like this, what issues have you run into?
  • What is the best method for checking the status of a url in PHP considering both accuracy and performance?
Edit
Report

1 Answer

1

Seems like it might be a job for curl.

If you're not stuck on PHP Perl's LWP might be an answer too.

answered 2008-10-28T19:33:47.130

Your Answer