2017-25 © Pedro Peláez
 

library icon-scraper

PHP Library to get the apple-touch-icons and favicon from a website.

image

mpclarkson/icon-scraper

PHP Library to get the apple-touch-icons and favicon from a website.

  • Friday, August 11, 2017
  • by hilenium
  • Repository
  • 2 Watchers
  • 14 Stars
  • 3,693 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 2 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Get Apple Touch Icons and Favicon from a Website

Build Status Scrutinizer Code Quality, (*1)

Overview

This library returns an array of apple-touch-icon and the favicon for a given url, sorted by width., (*2)

Requirements

PHP 5.4+, (*3)

Composer

Use Composer by adding the following lines in your composer.json:, (*4)

"require": {
    "mpclarkson/icon-scraper": "dev-master"
},

Usage


require_once('vendor/autoload.php'); $scraper = new \Mpclarkson\IconScraper\Scraper(); $icons = $scraper->get('http://hilenium.com'); foreach($icons as $icon) { $icon->getType(); //Returns favicon or apple-touch-icon $icon->getHref(); //Returns a url $icon->getSize(); //Returns an array of integers, or empty for favicons $icon->getWidth(); //Integer or null $icon->getHeight(); //Integer or null } //$icons looks like this: Array ( [0] => Mpclarkson\IconScraper\Icon Object ( [type:Mpclarkson\IconScraper\Icon:private] => favicon [href:Mpclarkson\IconScraper\Icon:private] => http://d1nhhppd50p5r.cloudfront.net/favicon.ico?1433897130 [size:Mpclarkson\IconScraper\Icon:private] => Array ( ) ) [1] => Mpclarkson\IconScraper\Icon Object ( [type:Mpclarkson\IconScraper\Icon:private] => apple-touch-icon [href:Mpclarkson\IconScraper\Icon:private] => http://d1nhhppd50p5r.cloudfront.net/css/96113be.css?1433897130 [size:Mpclarkson\IconScraper\Icon:private] => Array ( ) ) [2] => Mpclarkson\IconScraper\Icon Object ( [type:Mpclarkson\IconScraper\Icon:private] => apple-touch-icon [href:Mpclarkson\IconScraper\Icon:private] => https://d1nhhppd50p5r.cloudfront.net/icon57.png?1433897130 [size:Mpclarkson\IconScraper\Icon:private] => Array ( [0] => 57 [1] => 57 ) ) [3] => Mpclarkson\IconScraper\Icon Object ( [type:Mpclarkson\IconScraper\Icon:private] => apple-touch-icon [href:Mpclarkson\IconScraper\Icon:private] => http://d1nhhppd50p5r.cloudfront.net/icon72.png?1433897130 [size:Mpclarkson\IconScraper\Icon:private] => Array ( [0] => 72 [1] => 72 ) ) [4] => Mpclarkson\IconScraper\Icon Object ( [type:Mpclarkson\IconScraper\Icon:private] => apple-touch-icon [href:Mpclarkson\IconScraper\Icon:private] => https://d1nhhppd50p5r.cloudfront.net/icon76.png?1433897130 [size:Mpclarkson\IconScraper\Icon:private] => Array ( [0] => 76 [1] => 76 ) ) [5] => Mpclarkson\IconScraper\Icon Object ( [type:Mpclarkson\IconScraper\Icon:private] => apple-touch-icon [href:Mpclarkson\IconScraper\Icon:private] => https://d1nhhppd50p5r.cloudfront.net/icon114.png?1433897130 [size:Mpclarkson\IconScraper\Icon:private] => Array ( [0] => 114 [1] => 114 ) ) [6] => Mpclarkson\IconScraper\Icon Object ( [type:Mpclarkson\IconScraper\Icon:private] => apple-touch-icon [href:Mpclarkson\IconScraper\Icon:private] => https://d1nhhppd50p5r.cloudfront.net/icon120.png?1433897130 [size:Mpclarkson\IconScraper\Icon:private] => Array ( [0] => 120 [1] => 120 ) ) [7] => Mpclarkson\IconScraper\Icon Object ( [type:Mpclarkson\IconScraper\Icon:private] => apple-touch-icon [href:Mpclarkson\IconScraper\Icon:private] => https://d1nhhppd50p5r.cloudfront.net/icon144.png?1433897130 [size:Mpclarkson\IconScraper\Icon:private] => Array ( [0] => 144 [1] => 144 ) ) [8] => Mpclarkson\IconScraper\Icon Object ( [type:Mpclarkson\IconScraper\Icon:private] => apple-touch-icon [href:Mpclarkson\IconScraper\Icon:private] => http://d1nhhppd50p5r.cloudfront.net/icon152.png?1433897130 [size:Mpclarkson\IconScraper\Icon:private] => Array ( [0] => 152 [1] => 152 ) ) )

Todos

  • More tests
  • Improve code style

Credits

This library is significant fork of this library by Arthur Hoaro. Key changes include:, (*5)

  • Returns an array of icons, rather than just the favicon
  • Icons returned as Icon objects which include the following properties: type, href and size, and getters for width and height
  • No caching
  • PSR-4

Thanks goes to Hilenium., (*6)

The Versions

11/08 2017

dev-master

9999999-dev https://github.com/mpclarkson/icon-scraper

PHP Library to get the apple-touch-icons and favicon from a website.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

icon scraper favicon finder apple-touch-icon

21/03 2017

0.2.0

0.2.0.0 https://github.com/mpclarkson/icon-scraper

PHP Library to get the apple-touch-icons and favicon from a website.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

icon scraper favicon finder apple-touch-icon

16/07 2015

0.1.0

0.1.0.0 https://github.com/mpclarkson/icon-scraper

PHP Library to get the apple-touch-icons and favicon from a website.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

icon scraper favicon finder apple-touch-icon