Component evidence
Evaluates whether a crawler is permitted to index or follow links on a webpage based on robots.txt headers and meta tags.
// Source: https://github.com/spatie/crawler | License: MIT | Copyright Spatie bvba <info@spatie.be>
// Provided via justclaw.it.com; keep this notice with the code.
<?php
namespace Spatie\Crawler;
use Spatie\Robots\RobotsHeaders;
use Spatie\Robots\RobotsMeta;
class CrawlerRobots
{
protected RobotsHeaders $robotsHeaders;
protected RobotsMeta $robotsMeta;
public function __construct(
array $headers,
string $body,
protected bool $mustRespectRobots,
) {
$this->robotsHeaders = RobotsHeaders::create($headers);
$this->robotsMeta = RobotsMeta::create($body);
}
public function mayIndex(): bool
{
if (! $this->mustRespectRobots) {
return true;
}
if (! $this->robotsHeaders->mayIndex()) {
... (truncated -- full source via MCP)