1. Go to this page and download the library: Download timostamm/url-finder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
timostamm / url-finder example snippets
$documentUrl = 'http://domain.tld/products/all.html';
$finder = UrlFinder::create($html, $documentUrl);
foreach ($finder->find('*domain.tld/*.jpg') as $url) {
$newpath = '/images/' . $url->path->filename();
$url
->replacePath($newpath)
->makeAbsolute()
->clearHost();
}
$finder->getDocument(); // returns the updated HTML string
$urls = $finder
->find('*') // matches the entire absolute URL
->matchHost('*')
->matchPath('*')
->onlyHttps()
->matchFilenameNot('*.less');
// etc.
$urls->count();
$urls->toArray();
$urls->first();
foreach($urls as $url) {}