Add (custom crawl profile)

This commit is contained in:
2023-11-29 23:02:23 +08:00
parent ff7ff9309d
commit 5904418e8d
2 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Helpers\FirstParty\SitemapCrawler;
use Spatie\Crawler\CrawlProfiles\CrawlProfile;
use Psr\Http\Message\UriInterface;
class CustomCrawlProfile extends CrawlProfile
{
/** @var callable */
protected $callback;
public function shouldCrawlCallback(callable $callback): void
{
$this->callback = $callback;
}
public function shouldCrawl(UriInterface $url): bool
{
if ($url->getQuery() !== '') {
return false;
}
return ($this->callback)($url);
}
}