diff --git a/src/ChromeHeadless.php b/src/ChromeHeadless.php index 366b1c4..72af42a 100644 --- a/src/ChromeHeadless.php +++ b/src/ChromeHeadless.php @@ -2,6 +2,7 @@ namespace ChromeHeadless; +use ChromeHeadless\Exceptions\CloudflareProtection; use Symfony\Component\Process\Process; use Symfony\Component\DomCrawler\Crawler; use ChromeHeadless\Exceptions\EmptyDocument; @@ -59,6 +60,10 @@ public function setHtml(string $html) throw new EmptyDocument($this->url); } + if (strpos($html, 'cf-browser-verification cf-im-under-attack') !== false) { + throw new CloudflareProtection($this->url); + } + $this->html = $html; return $this; diff --git a/src/Exceptions/CloudflareProtection.php b/src/Exceptions/CloudflareProtection.php new file mode 100644 index 0000000..627ccef --- /dev/null +++ b/src/Exceptions/CloudflareProtection.php @@ -0,0 +1,13 @@ +