PHP code example of yoozi / miner

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

    

yoozi / miner example snippets


// Use the Readability Parser.
$extractor->getConfig()->set('parser', 'readability');

// Or...use the Hybrid Parser.
// $extractor->getConfig()->set('parser', 'hybrid');
// Or...use the Meta Parser.
// $extractor->getConfig()->set('parser', 'meta');



use Yoozi\Miner\Extractor;
use Buzz\Client\Curl;

$extractor = new Extractor();

// Use the Hybrid Parser.
$extractor->getConfig()->set('parser', 'hybrid');
// Strip all HTML tags in the description we parsed.
$extractor->getConfig()->set('strip_tags', true);

$meta = $extractor->fromUrl('http://www.example.com/', new Curl)->run();
var_dump($meta);

array(9) {
  ["title"]=>
  string(14) "Example Domain"
  ["author"]=>
  NULL
  ["keywords"]=>
  array(0) {
  }
  ["description"]=>
  string(220) "
    Example Domain
    This domain is established to be used for illustrative examples in documents. You may use this
    domain in examples without prior coordination or asking for permission.
    More information...
"
  ["image"]=>
  NULL
  ["url"]=>
  string(23) "http://www.example.com/"
  ["host"]=>
  string(22) "http://www.example.com"
  ["domain"]=>
  string(11) "example.com"
  ["favicon"]=>
  string(52) "http://www.google.com/s2/favicons?domain=example.com"
}

    php composer install
    

    php composer update