PHP - 如何在 Firefox 中获取主要的 HTML 内容,如阅读器模式

标签 php file-get-contents html-content-extraction

在 android Firefox 应用程序和 safari iPad 中,我们只能通过“阅读器模式”阅读主要内容。 read more... 如何用 PHP 只识别 HTML 中的主要内容?

我需要通过 php 检测主要新闻,如 Firefox 或 safari

例如,我通过以下代码从 bbcsite.com/news/123 获取新闻:

<?php
    $html = file_get_contents('http://bbcsite.com/news/123');
?>

然后只显示没有广告的主要新闻,并且...就像 Firefox 和 safari。

我找到了 fivefilters.org .本站可以获取内容!!!

谢谢

最佳答案

名为 PHP Goose 的新 PHP 库似乎在这方面也做得很好。它非常易于使用并且是 Composer友好。

这是实际自述文件中给出的用法示例:

use Goose\Client as GooseClient;

$goose = new GooseClient();
$article = $goose->extractContent('http://url.to/article');

$title = $article->getTitle();
$metaDescription = $article->getMetaDescription();
$metaKeywords = $article->getMetaKeywords();
$canonicalLink = $article->getCanonicalLink();
$domain = $article->getDomain();
$tags = $article->getTags();
$links = $article->getLinks();
$movies = $article->getMovies();
$articleText = $article->getCleanedArticleText();
$entities = $article->getPopularWords();
$image = $article->getTopImage();
$allImages = $article->getAllImages();

关于PHP - 如何在 Firefox 中获取主要的 HTML 内容,如阅读器模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17733275/

相关文章:

php - file_get_contents 编码 - 适用于 Chrome 和 Safari,不适用于 Firefox、Opera、IE

php - file_get_contents 或 fopen 用于读取几 MB 的 php ://input?

java - 从 HTML Java 中提取文本

python - 使用 Python 从 HTML 文件中提取文本

php - 检测短信 : browser support on Browser

php - 如何仅在具有不同行的情况下更新 SQL

php - 查询在 laravel 中返​​回错误的输出结果

php - 使用 Yii,有没有办法通过 CDbCriteria 添加 AS 进行查询

php - stream_get_contents 是否比 file_get_contents 级别更低且速度更快?

java - 如何使用jsp从网页中提取链接?