Created: 2012-03-20 08:47
Updated: 2019-01-09 19:04
License: mit

HTML Document Link URL Finder

Get a collection of full absolute URLs for links in an HTML document.


This project has external dependencies managed with composer. Get and install this first.

# Make a suitable project directory
mkdir ~/html-document-link-url-finder && cd ~/html-document-link-url-finder

# Clone repository
git clone .

# Retrieve/update dependencies
composer.phar update


The "Hello World" example

$sourceUrl = '';

echo "Finding link URLs in ".$sourceUrl."\n";

$sourceContent = file_get_contents($sourceUrl);

$finder = new \webignition\HtmlDocumentLinkUrlFinder\HtmlDocumentLinkUrlFinder();

$urls = $finder->getAllUrls();

echo "Found ".count($urls)." urls\n";

if (isset($_GET['verbose'])) {
    foreach ($urls as $url) {
        echo $url . "\n";

echo "\n";
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more