shevabam/php-extract-meta-url 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shevabam/php-extract-meta-url

最新稳定版本:2.2.0

Composer 安装命令:

composer require shevabam/php-extract-meta-url

包简介

Extract title, description, keywords, image, favicon and RSS from URL

README 文档

README

PHP Extract Meta URL is a very simple library allowing to obtain various information of a Web site from its URL:

  • title
  • description
  • keywords
  • image
  • favicon
  • RSS feeds
  • Twitter card data

Requirements

  • PHP 7.4+
  • PHP cURL extension
  • PHP json extension

Installation

With Composer, run this command:

composer require shevabam/php-extract-meta-url

Usage

Simple example:

<?php
require 'vendor/autoload.php';

use PhpExtractMetaUrl\PhpExtractMetaUrl;

try {
    $url = 'https://www.gadgets360.com/science/news/blue-origin-jeff-bezos-new-shepard-ns-23-nasa-3339832';

    $extractor = new PhpExtractMetaUrl($url);
    $extractor->setFormat('array'); // default: json
    $result = $extractor->getResult();

    var_dump($result);
} catch (Exception $e) {
    echo $e->getMessage();
}

Returns with default format (json):

{
    "website": {
        "url": "https://www.gadgets360.com/science/news/blue-origin-jeff-bezos-new-shepard-ns-23-nasa-3339832",
        "scheme": "https",
        "host": "www.gadgets360.com",
        "path": "/science/news/blue-origin-jeff-bezos-new-shepard-ns-23-nasa-3339832"
    },
    "title": "Blue Origin Rocket Fails Shortly After Lift-Off: All Details | Technology News",
    "description": "A Blue Origin rocket has failed mid-flight shortly after its lift-off a day ago. This has caused the rocket to abort its cargo capsule to safety before crashing into the Texas desert. The rocket aimed to send NASA-funded experiments and other payloads to the edge of the space. The booster crashed within the designated hazard area.",
    "keywords": [
        "blue origin jeff bezos new shepard ns 23 nasa blue origin",
        "nasa",
        "jeff bezos",
        "new shepard"
    ],
    "image": "https://i.gadgets360cdn.com/large/blue_moon_bezos_reuters_1624520858507.jpg",
    "favicon": "https://www.gadgets360.com/favicon.ico",
    "rss": [
        "https://feeds.feedburner.com/gadgets360-latest"
    ]
}

With $extractor->setFormat('array'):

Array
(
    [website] => Array
        (
            [url] => https://www.gadgets360.com/science/news/blue-origin-jeff-bezos-new-shepard-ns-23-nasa-3339832
            [scheme] => https
            [host] => www.gadgets360.com
            [path] => /science/news/blue-origin-jeff-bezos-new-shepard-ns-23-nasa-3339832
        )

    [title] => Blue Origin Rocket Fails Shortly After Lift-Off: All Details | Technology News
    [description] => A Blue Origin rocket has failed mid-flight shortly after its lift-off a day ago. This has caused the rocket to abort its cargo capsule to safety before crashing into the Texas desert. The rocket aimed to send NASA-funded experiments and other payloads to the edge of the space. The booster crashed within the designated hazard area.
    [keywords] => Array
        (
            [0] => blue origin jeff bezos new shepard ns 23 nasa blue origin
            [1] => nasa
            [2] => jeff bezos
            [3] => new shepard
        )

    [image] => https://i.gadgets360cdn.com/large/blue_moon_bezos_reuters_1624520858507.jpg
    [favicon] => https://www.gadgets360.com/favicon.ico
    [rss] => Array
        (
            [0] => https://feeds.feedburner.com/gadgets360-latest
        )

)

统计信息

  • 总下载量: 104
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2022-11-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固