34 lines
926 B
PHP
34 lines
926 B
PHP
<?php
|
|
|
|
namespace App\Libraries\MyCrawler;
|
|
|
|
use App\Libraries\CommonLibrary;
|
|
use Symfony\Component\DomCrawler\Crawler;
|
|
|
|
abstract class MyCrawlerLibrary extends CommonLibrary
|
|
{
|
|
protected $_mySocket = null;
|
|
protected $_myStorage = null;
|
|
protected function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
abstract public function execute(): void;
|
|
abstract protected function getMySocket(): mixed;
|
|
abstract protected function getMyStorage(): mixed;
|
|
final protected function getSelector(string $content, string $tag): Crawler
|
|
{
|
|
$crawler = new Crawler($content);
|
|
if ($this->getDebug()) {
|
|
log_message("debug", sprintf(
|
|
"\n---------%s----------\ntag:%s\n%s\n-------------------\n",
|
|
__FUNCTION__,
|
|
$tag,
|
|
$content
|
|
));
|
|
exit;
|
|
}
|
|
return $crawler->filter($tag);
|
|
}
|
|
}
|