Download the PHP package lukaswhite/php-meta-tags-parser without Composer
On this page you can find all versions of the php package lukaswhite/php-meta-tags-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lukaswhite/php-meta-tags-parser
More information about lukaswhite/php-meta-tags-parser
Files in lukaswhite/php-meta-tags-parser
Package php-meta-tags-parser
Short Description A PHP package for parsing meta tags in HTML documents
License MIT
Informations about the package php-meta-tags-parser
PHP Meta Tags Parser
Extracts metadata (title, description, Open Graph etc) from the content of a web page.
Note that this library simply deals with raw HTML, rather than try to tie you down to one particular method for retrieving the content of an external URL. (I usually use Guzzle, but to make it a dependency might cause difficulties in terms of versioning.)
Installation
Usage
Using the result
The parse()
method returns an object that encapsulates any page data it's extracted from the provided HTML.
It will also extract RSS and/or Atom feeds; getFeeds()
returns an array of instances of the Feed
class:
The getFeeds()
method accepts an optional $type
argument, to choose one or the other:
Cleansing the data
The package ships with a very simple string cleanser; essentially it just decodes any HTML entities. You're free to provide your own cleanser; just implement the CleansesStrings
interface, and provide an instance to the parser's constructor. It simply needs to provide a run()
method, that accepts a string and returns the cleansed version.
Sanitizing the data
The package ships with a very simple string sanitzer; under the hood it simply uses the strip_tags()
function. If you wish to provide your own sanitizer, just implement the SanitizesStrings
interface, and provide an instance to the parser's constructor. It simply needs to provide a run()
method, that accepts a string and returns the sanitized version.