patricksavalle / content-syndication
处理HTML元数据检索、RSS、ATOM、URL解析和规范化的辅助库
v0.1
2021-09-02 13:16 UTC
Requires
- php: >=7.3
- ext-curl: *
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
This package is auto-updated.
Last update: 2024-09-22 21:18:45 UTC
README
包含通常用于内容分发的实用函数的库。
- 提取HTML元数据(og:tags、twitter:tags等)
- URL规范化和绝对化
- 文本解析和转换
- RSS/ATOM读取
- 在archive.org存储和检索
它被用于以下生产系统:https://zaplog.pro (https://gitlab.com/zaplog)
使用 Composer 安装
-
更新你的
composer.json
以要求patricksavalle/slim-request-params
。 -
运行
composer install
以将 slim-request-params 添加到你的供应商文件夹。{ "require": { "patricksavalle/php-content-syndication": "^0.1" } }
-
包含在你的源中。
<?php require './vendor/autoload.php';
使用方法
检索HTML元数据
返回的URL将被规范化。
return (new HtmlMetadata)("https://gizmodo.com/the-real-reason-gas-prices-are-so-high-right-now-1848088360");
Array
(
[url] => https://gizmodo.com/the-real-reason-gas-prices-are-so-high-right-now-1848088360
[title] => The Real Reason Gas Prices Are So High Right Now
[description] => It's not the Biden administration's energy policies nor Big Oil illegally manipulating prices.
[image] => https://i.kinja-img.com/gawker-media/image/upload/c_fill,f_auto,fl_progressive,g_center,h_675,pg_1,q_80,w_1200/1aafc02b452854117b46237d555e4879.jpg
[video] =>
[video:type] =>
[video:release_date] =>
[video:duration] =>
[video:series] =>
[site_name] => Gizmodo
[language] => en
[rss] => https://gizmodo.com/rss
[atom] =>
[author] =>
[copyright] =>
[keywords] => Array
(
[0] => OPEC
[1] => american petroleum institute
[2] => Business
[3] => Finance
[4] => Primary sector of the economy
[5] => Joe Biden
[6] => Cartels
[7] => Ed Markey
[8] => Big Oil
[9] => Clark Williams-Derry
[10] => Price of oil
[11] => Petroleum industry
[12] => Chronology of world oil market events
[13] => Petroleum
[14] => Energy
[15] => West Texas Intermediate
[16] => Gizmodo
)
)