flavioheleno / favicon
一个用于解析页面和网页清单以提取favicon图片的库
dev-main
2022-07-11 17:22 UTC
Requires
- php: >=8.1
- ext-dom: *
- ext-xml: *
- innmind/url-resolver: ^4.1
- masterminds/html5: ^2.7
- psr/http-client: ^1.0
- psr/http-client-implementation: ^1.0
- psr/http-factory: ^1.0
- psr/http-factory-implementation: ^1.0
- ramsey/collection: ^1.2
Requires (Dev)
- infection/infection: ^0.26
- kriswallsmith/buzz: ^1.2
- nyholm/psr7: ^1.5
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^9.5
- psy/psysh: ^0.11
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.6
- vimeo/psalm: ^4.8
This package is auto-updated.
Last update: 2024-09-11 22:13:31 UTC
README
一个用于解析页面和网页清单以提取favicon图片的库
安装
安装此库的最佳方式是使用Composer包管理器。
要安装,请运行以下命令
php composer.phar require flavioheleno/favicon
此包与任何发送HTTP消息的具体库无关。相反,它使用PSR-17(HTTP工厂)和PSR-18(HTTP客户端)来让开发者选择他们想要的PSR-17和PSR-18实现。
如果您不使用任何特定的PSR-17或PSR-18库并希望立即开始,您应该运行以下命令
php composer.phar require flavioheleno/favicon kriswallsmith/buzz nyholm/psr7
这将安装库本身以及一个PSR-17实现(nyholm/psr7)和一个PSR-18实现(kriswallsmith/buzz)。
您可以用任何提供HTTP消息实现(PSR-17)或HTTP客户端实现(PSR-18)的替代库替换这些库。
使用方法
提取所有图标
use Buzz\Client\Curl; use Favicon\Extractor; use Nyholm\Psr7\Factory\Psr17Factory; $extractor = new Extractor( new Curl(new Psr17Factory()), new Psr17Factory() ); $favicon = $extractor->from('https://twitter.com'); foreach ($favicon->getIconCollection() as $icon) { echo $icon->getRelationship(), ': ', $icon->getUrl(), PHP_EOL; }
manifest: https://abs.twimg.com/responsive-web/client-web-legacy/icon-default.ee534d85.png
manifest: https://abs.twimg.com/responsive-web/client-web-legacy/icon-default-large.8e027b65.png
manifest: https://abs.twimg.com/responsive-web/client-web-legacy/icon-default-maskable.2fd29c85.png
manifest: https://abs.twimg.com/responsive-web/client-web-legacy/icon-default-maskable-large.ee2b7aa5.png
shortcut icon: http://abs.twimg.com/favicons/twitter.2.ico
apple-touch-icon: https://abs.twimg.com/responsive-web/client-web-legacy/icon-ios.b1fc7275.png
许可证
此库根据MIT许可证授权。