PHP code example of the-3labs-team / laravel-readability

1. Go to this page and download the library: Download the-3labs-team/laravel-readability 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/ */

    

the-3labs-team / laravel-readability example snippets


use The3LabsTeam\LaravelReadability\Facades\Readability;

$html = '<html>...</html>';
$parsed = Readability::parse($html);
$title = $parsed->getTitle();

$html = '<html>...</html>';
$parsed = Readability::parse($html);

$title = $parsed->getTitle();
$content = $parsed->getContent();
$excerpt = $parsed->getExcerpt();
$author = $parsed->getAuthor();
$direction = $parsed->getDirection();
$image = $parsed->getImage();
$images = $parsed->getImages();

use The3LabsTeam\LaravelReadability\Readability as ReadabilityClass;

$html = '<html>...</html>';
$parse = (new ReadabilityClass($html))
->getSourceList(
    domainWhitelist: ['example.com', 'another-example.com/some-path'],
    tagsToExtract: ['a', 'iframe', 'text'] // Optional, default is ['a', 'iframe']
)
->parse();
$content = $parsed->getContent();