hedii/extractors

提取器是一个包,可以在HTML DOM中查找特定类型的资源。

2.1.0 2018-05-18 09:53 UTC

This package is auto-updated.

Last update: 2024-09-18 19:09:08 UTC


README

Build Status

提取器

提取器是一个包,可以在HTML DOM中查找特定类型的资源。目前,只有两种资源类型可用:URL和电子邮件。找到的资源以数组形式返回。

可以扩展Extractor类以添加更多资源类型。

安装

通过Composer

composer require hedii/extractors

使用方法

目前,只有两种资源类型可用:URL和电子邮件。

// require composer autoloader
require '/path/to/vendor/autoload.php';

// instantiate 
$extractor = new \Hedii\Extractors\Extractor();

// get all the urls on example.com page dom
$urls = $extractor->searchFor(['urls'])
    ->at('http://example.com')
    ->get();

// get all the emails on example.com page dom
$emails = $extractor->searchFor(['emails'])
    ->at('http://example.com')
    ->get();

// get all the urls and emails on example.com page dom
$urlsAndEmails = $extractor->searchFor(['urls', 'emails'])
    ->at('http://example.com')
    ->get();

测试

composer test