balpom/links-extractor
最新稳定版本:v1.1.2
Composer 安装命令:
composer require balpom/links-extractor
包简介
Extract all links from string in extended PSR-13 format.
关键字:
README 文档
README
Extract all links from string and provide it in extended PSR-13 format.
This extractor extract all HTTP links from given string (or PSR-7 Response object) and provide it in Balpom\WebLink\EvolvableWebLinkInterface format (which extends Psr\Link\EvolvableLinkInterface (https://www.php-fig.org/psr/psr-13/) format) as collection in Psr\Link\LinkProviderInterface format (see also https://www.php-fig.org/psr/psr-13/).
Requirements
- PHP >= 8.1
Installation
Using composer (recommended)
composer require balpom/links-extractor
How to use
There are two extractor realisation in this package: Balpom\LinksExtractor\SimpleExtractor and Balpom\LinksExtractor\Extractor
SimpleExtractor usage samples:
$css = 'div.cls1{background-image:url(/image-file-1.jpg);} span.cls2{background-image:url(/image-file-2.png);}'; $extractor = new SimpleExtractor($css, 'text/css'); $linksProvider = $extractor->extract(); print_r($linksProvider->getLinks());
$html = '<a href="/page.html">ABC</a><a href="/page.html">XYZ</a> <img src="/image-file-3.gif"><div>Else one <img src="/image-file-3.gif"></div>'; $extractor = new SimpleExtractor($html, 'text/html'); $linksProvider = $extractor->extract(); print_r($linksProvider->getLinks());
Extractor works also as a SimpleExtractor, but takes as a constructor argument an Psr\Http\Message\ResponseInterface object (https://www.php-fig.org/psr/psr-7/), not a string.
License
MIT License See LICENSE.MD
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-23