PHP Classes
elePHPant
Icontem

Link Checker: Find broken links in a Web site

Recommend this page to a friend!
  All requests RSS feed  >  Link Checker  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

Link Checker

A request is featured when there is no good recommended package on the site when it is posted. Edit

by Stephen Johns - 2 days ago (2017-08-28)

Find broken links in a Web site

This request is clear and relevant.
This request is not clear or is not relevant.

+2

I need a way to find broken links in a Web site.

Ask clarification

2 Recommendations

PHP CURL Component: Compose and execute HTTP requests with Curl

This recommendation solves the problem.
This recommendation does not solve the problem.

+1

by Fernando Reputation 60 - 23 hours ago (2017-08-30) Comment

I do not think there is a package to handle that. It's basically send a request with the links and analyze the response. Use Curl to accomplish that.


PHP HTTP protocol client: HTTP client to access Web site pages

This recommendation solves the problem.
This recommendation does not solve the problem.

+1

by Dave Smith Reputation 6395 - 2 days ago (2017-08-28) Comment

It is a multi-part process. First you need to scrape the website and retrieve the links, which is fairly easy. Then you can use this class to send http requests to the linked sites and capture the response to check if they are returning a good request.

  • 2 Comments
  • 1. by Till Wehowski - 22 hours ago (2017-08-30) Reply

    I agree with Dave Smith to recommend https://www.phpclasses.org/package/3-PHP-HTTP-client-to-access-Web-site-pages.html for testing the http response code, you can fetch only the headers and check for the response code? To do the first task, fetching the links, I would recommend:

    • either php.net/manual/de/class.domdocument.php
    • or (handling invalid HTML) simplehtmldom.sourceforge.net/
    • or just a simple REGEX:

      $regexp = "<a\s[^>]href=(\"??)([^\" >]?)\\1[^>]>(.)<\/a>"; preg_match_all("/$regexp/siU", $this->content, $matches);

  • 2. by Till Wehowski - 22 hours ago (2017-08-30) in reply to comment 1 by Till Wehowski Reply

    Somehow the regex in my answer was broken by the site, here it is as gist gist.github.com/wehowski/afc811cb4eb727e97e2a75b1b9d3e3c6


Recommend package
: 
: