darkfriend/schema-org-parser
最新稳定版本:1.0.0
Composer 安装命令:
composer require darkfriend/schema-org-parser
包简介
Parse schema.org microdata from HTML documents with ease. PHP Implementation of W3C Microdata to JSON Specification.
README 文档
README
It`s fork from yusufkandemir/microdata-parser for support php7.
This package aims to implement W3C Microdata to JSON Specification.
microdata-parser extracts microdata from documents.
Installation
Via Composer
$ composer require darkfriend/schema-org-parser
Usage
PHP
use Darkfriend\SchemaOrgParser\Microdata; $microdata = Microdata::fromHTMLFile('source.html')->toJSON(); /* Other sources: fromHTML() // from HTML string fromDOMDocument() // from DOMDocument object Other output methods: toArray() // to Associtive PHP Array toObject() // to PHP Object (stdClass) */
Source as HTML
<!-- source.html --> <div itemscope itemtype="http://schema.org/Product"> <img itemprop="image" src="http://shop.example.com/test_product.jpg" /> <a itemprop="url" href="http://shop.example.com/test_product"> <span itemprop="name">Test Product</span> </a> </div>
Result as JSON
{
"items": [
{
"type": [ "http://schema.org/Product" ],
"properties": {
"image": [ "http://shop.example.com/test_product.jpg" ],
"url": [ "http://shop.example.com/test_product" ],
"name": [ "Test Product" ]
}
}
]
}
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-17