美文网首页
php laravel 轻松自动提取网页内容

php laravel 轻松自动提取网页内容

作者: 大萝卜2022 | 来源:发表于2022-10-27 15:40 被阅读0次

安装

composer require fivefilters/readability.php

代码

use andreskrey\Readability\Readability;
use andreskrey\Readability\Configuration;
use andreskrey\Readability\ParseException;

$readability = new Readability(new Configuration());

$html = file_get_contents('http://your.favorite.newspaper/article.html');

try {
    $readability->parse($html);
    echo $readability;
} catch (ParseException $e) {
    echo sprintf('Error processing text: %s', $e->getMessage());
}


相关文章

网友评论

      本文标题:php laravel 轻松自动提取网页内容

      本文链接:https://www.haomeiwen.com/subject/vhkftdtx.html