From 89b8be514727b37bda3c7b2acb527335b9bdbfbf Mon Sep 17 00:00:00 2001 From: lolcat Date: Tue, 18 Aug 2026 06:55:01 -0400 Subject: [PATCH] detect brave captcha --- scraper/brave.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/scraper/brave.php b/scraper/brave.php index 5573133..2efaefb 100644 --- a/scraper/brave.php +++ b/scraper/brave.php @@ -383,6 +383,8 @@ class brave{ // load html $this->fuckhtml->load($html); + $this->detect_captcha($html); + /* Get next page "token" */ @@ -1175,6 +1177,8 @@ class brave{ // load html $this->fuckhtml->load($html); + $this->detect_captcha($html); + // get npt $out["npt"] = $this->generatenextpagetoken( @@ -1270,6 +1274,9 @@ class brave{ fclose($handle);*/ $this->fuckhtml->load($html); + + $this->detect_captcha($html); + $json = $this->get_js(); foreach( @@ -1374,6 +1381,8 @@ class brave{ $this->fuckhtml->load($html); + $this->detect_captcha($html); + $out = [ "status" => "ok", "npt" => null, @@ -1853,4 +1862,29 @@ class brave{ ) ); } + + private function detect_captcha(){ + + $title = + $this->fuckhtml + ->getElementsByTagName( + "title" + ); + + if(count($title) === 0){ + + throw new Exception("Brave returned a malformed page"); + } + + $title = + strtolower( + $this->fuckhtml + ->getTextContent($title[0]) + ); + + if($title == "human verification"){ + + throw new Exception("Brave returned a Captcha"); + } + } }