/** * Called when the crawler has crawled the given url. * * @param \Spatie\Crawler\Url $url * @param \Psr\Http\Message\ResponseInterface|null $response * * @return string */ public function hasBeenCrawled(Url $url, $response) { $statusCode = parent::hasBeenCrawled($url, $response); if ($this->isSuccessOrRedirect($statusCode)) { return; } $reason = $response ? $response->getReasonPhrase() : ''; $this->log->warning("{$statusCode} {$reason} - {$url}"); }
/** * Called when the crawler has crawled the given url. * * @param \Spatie\Crawler\Url $url * @param \Psr\Http\Message\ResponseInterface|null $response * @param \Spatie\Crawler\Url $foundOnUrl * * @return string */ public function hasBeenCrawled(Url $url, $response, Url $foundOnUrl = null) { $statusCode = parent::hasBeenCrawled($url, $response); if ($this->isSuccessOrRedirect($statusCode)) { return; } $reason = $response ? $response->getReasonPhrase() : ''; $logMessage = "{$statusCode} {$reason} - {$url}"; if ($foundOnUrl) { $logMessage .= " (found on {$foundOnUrl}"; } $this->log->warning($logMessage); }