Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yusufkandemir/microdata-parser
Parse microdata from HTML documents with ease. PHP Implementation of W3C Microdata to JSON Specification.
https://github.com/yusufkandemir/microdata-parser
microdata parser php-library
Last synced: 2 months ago
JSON representation
Parse microdata from HTML documents with ease. PHP Implementation of W3C Microdata to JSON Specification.
- Host: GitHub
- URL: https://github.com/yusufkandemir/microdata-parser
- Owner: yusufkandemir
- License: mit
- Created: 2018-11-14T20:11:17.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-05-01T16:24:21.000Z (8 months ago)
- Last Synced: 2024-10-14T09:39:07.981Z (3 months ago)
- Topics: microdata, parser, php-library
- Language: PHP
- Size: 77.1 KB
- Stars: 15
- Watchers: 3
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# microdata-parser
[![Latest Version on Packagist][ico-version]][link-packagist]
[![PHP Version Support][ico-php-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Tests][ico-tests]][link-tests]
[![Quality Checks][ico-code-quality]][link-code-quality]
[![Total Downloads][ico-downloads]][link-packagist]This package aims to implement [W3C Microdata to JSON Specification](https://www.w3.org/TR/microdata/#json).
**microdata-parser** extracts microdata from documents.
## Installation
Via Composer
```bash
$ composer require yusufkandemir/microdata-parser
```## Usage
##### PHP
```php
use YusufKandemir\MicrodataParser\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
```html
```##### Result as JSON
```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
```bash
$ composer test
```## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## Credits
- [Yusuf Kandemir][link-author]
- [All Contributors][link-contributors]## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
[ico-version]: https://img.shields.io/packagist/v/yusufkandemir/microdata-parser.svg?style=flat-square
[ico-php-version]: https://img.shields.io/packagist/php-v/yusufkandemir/microdata-parser?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-tests]: https://img.shields.io/github/actions/workflow/status/yusufkandemir/microdata-parser/run-tests.yml?style=flat-square&logo=github&label=tests
[ico-code-quality]: https://img.shields.io/github/actions/workflow/status/yusufkandemir/microdata-parser/analyze-quality.yml?style=flat-square&logo=github&label=quality
[ico-downloads]: https://img.shields.io/packagist/dt/yusufkandemir/microdata-parser.svg?style=flat-square[link-packagist]: https://packagist.org/packages/yusufkandemir/microdata-parser
[link-tests]: https://github.com/yusufkandemir/microdata-parser/actions/workflows/run-tests.yml
[link-code-quality]: https://github.com/yusufkandemir/microdata-parser/actions/workflows/analyze-quality.yml
[link-author]: https://github.com/yusufkandemir
[link-contributors]: ../../contributors