PHP code example of balpom / links-extractor

1. Go to this page and download the library: Download balpom/links-extractor 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/ */

    

balpom / links-extractor example snippets


$css = 'div.cls1{background-image:url(/image-file-1.jpg);}
span.cls2{background-image:url(/image-file-2.png);}';

$extractor = new SimpleExtractor($css, 'text/css');
$linksProvider = $extractor->extract();
print_r($linksProvider->getLinks());

$html = '<a href="/page.html">ABC</a><a href="/page.html">XYZ</a>
<img src="/image-file-3.gif"><div>Else one <img src="/image-file-3.gif"></div>';

$extractor = new SimpleExtractor($html, 'text/html');
$linksProvider = $extractor->extract();
print_r($linksProvider->getLinks());