the-3labs-team / laravel-readability
Laravel Readability is a supercharged PHP client that makes it easy to extract and manipulate the main content of a web page.
Requires
- php: ^8.1
- fivefilters/readability.php: ^3.1
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.0
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.5
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
README
Laravel Readability
This package is a Laravel wrapper for readability.php. It provides a simple way to extract the main content from a webpage.
Installation
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.
Usage
$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();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.