19 lines
473 B
PHP
19 lines
473 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services;
|
|
|
|
class PolitenessService
|
|
{
|
|
public function minDelayFor(string $domain): int
|
|
{
|
|
/** @var RobotsService $robotsService */
|
|
$robotsService = resolve(RobotsService::class);
|
|
$crawlDelay = $robotsService->crawlDelayFor($domain, config('crawler.user_agent'));
|
|
|
|
$configValue = config('crawler.min_domain_delay_seconds', 10);
|
|
|
|
return max($crawlDelay ?? 0, $configValue);
|
|
}
|
|
}
|