Skip to content

PHP library for extracting meta tags from a URL or HTML content.

License

Notifications You must be signed in to change notification settings

martinille/meta-tag-extraction

Repository files navigation

Meta Tag Extraction

Tests Coverage Status License

About

Meta Tag Extraction is a light-weight library for extracting meta tags from HTML content.

It allows you to:

  • get all meta tags from URL or HTML content (including title, charset, and html[lang] attribute),
  • set custom cache provider for caching the results of web scraping (using PSR-16 Psr\SimpleCache\CacheInterface),
  • set custom HTTP client for web scraping (using PSR-18 Psr\Http\Client\ClientInterface),

This library can be considered as extended alternative for get_meta_tags() function.

Requirements

  • PHP 8.1 or higher
  • PHP DOM extension

Installation

composer require martinille/meta-tag-extraction

Usage

use MartinIlle\MetaTagExtraction\MetaTagExtraction;

$url = 'https://example.com';
$metaTagExtraction = new MetaTagExtraction();

$metaTags = $metaTagExtraction->extractFromUrl($url);

Examples

Extracting meta tags from HTML content: docs/MetaTagExtraction_html_example.php

Extracting meta tags from a URL: docs/MetaTagExtraction_url_example.php

More examples: docs/index.md

Unit Testing

Unit tests:

composer test

Unit tests with coverage:

composer test:coverage

About

PHP library for extracting meta tags from a URL or HTML content.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages