如何在 laravel 中使用 simple_html_dom

How use simple_html_dom in laravel

我想在我的 Laravel 项目中使用 simple_html_dom。但我无法将此包添加到我的项目中。

如何在 laravel 中使用 simple_html_dom?

有几种方法,其中一种使用作曲家。 运行 来自命令行的这个命令:

composer require sunra/php-simple-html-dom-parser

用法示例:

use Sunra\PhpSimple\HtmlDomParser;

$document = HtmlDomParser::str_get_html($html_text);
$document->find($selector);