28 lines
674 B
PHP
28 lines
674 B
PHP
<?php
|
|
|
|
namespace App\Libraries;
|
|
|
|
use Symfony\Component\DomCrawler\Crawler;
|
|
|
|
class MyCrawlerLibrary extends CommonLibrary
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
final public function create($html): Crawler
|
|
{
|
|
return new Crawler($html);
|
|
}
|
|
public function getNodes(Crawler $crawler, array $options, $nodes = []): array
|
|
{
|
|
$crawler->filter($options["tag"])->each(
|
|
function (Crawler $node) use (&$options, &$nodes): void {
|
|
log_message("debug", sprintf("getNode-> %s", $options["tag"]));
|
|
$nodes[] = $node;
|
|
}
|
|
);
|
|
return $nodes;
|
|
}
|
|
}
|