Laravel Readability is a supercharged PHP client that makes it easy to extract and manipulate the main content of a web page.
the-3labs-team/laravel-readability is a Laravel package for laravel readability is a supercharged php client that makes it easy to extract and manipulate the main content of a web page..
It currently has 17 GitHub stars and 496 downloads on Packagist (latest version v1.0.5).
Install it with composer require the-3labs-team/laravel-readability.
Discover more Laravel packages by the-3labs-team
or browse all Laravel packages to compare alternatives.
Last updated

This package is a Laravel wrapper for readability.php. It provides a simple way to extract the main content from a webpage.
You can install the package via composer:
composer require the-3labs-team/laravel-readability
Since it uses the readability.php package, you will need the following PHP extensions:
$ sudo apt-get install php7.4-xml php7.4-mbstring
Please change the version according to your PHP version.
use The3LabsTeam\LaravelReadability\Facades\Readability;
$html = '<html>...</html>';
$parsed = Readability::parse($html);
$title = $parsed->getTitle();
You can use the same methods as the original package. Please refer to the readability.php documentation.
$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();
´$content´ will contain the list of sources in the article.
...
<p>Source list: https://example.com/source1, https://example.com/source2</p>
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.