Automation/app/Libraries/MyCrawlerLibrary.php
2024-09-14 20:44:49 +09:00

34 lines
916 B
PHP

<?php
namespace App\Libraries;
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);
}
}