From 47a7a2a224620bcbeea822c9201bc76c94f191fe Mon Sep 17 00:00:00 2001 From: lolcat Date: Sat, 1 Feb 2025 22:51:44 -0500 Subject: [PATCH] brave pagination fix --- scraper/brave.php | 77 ++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/scraper/brave.php b/scraper/brave.php index eb5b3b0..e6f5908 100644 --- a/scraper/brave.php +++ b/scraper/brave.php @@ -403,7 +403,7 @@ class brave{ $nextpage = $this->fuckhtml - ->getElementsByClassName("btn", "a"); + ->getElementsByClassName("button", "a"); if(count($nextpage) !== 0){ @@ -1777,42 +1777,57 @@ class brave{ $nextpage = $this->fuckhtml - ->getElementsByClassName("btn", "a"); + ->getElementById( + "pagination", + "div" + ); - if(count($nextpage) !== 0){ + if($nextpage){ + + $this->fuckhtml->load($nextpage); $nextpage = - $nextpage[count($nextpage) - 1]; - - if( - strtolower( - $this->fuckhtml - ->getTextContent( - $nextpage - ) - ) == "next" - ){ - - preg_match( - '/offset=([0-9]+)/', - $this->fuckhtml->getTextContent($nextpage["attributes"]["href"]), - $nextpage + $this->fuckhtml + ->getElementsByClassName( + "button", + "a" ); + + if(count($nextpage) !== 0){ - return - $this->backend->store( - json_encode( - [ - "q" => $q, - "offset" => (int)$nextpage[1], - "nsfw" => $nsfw, - "country" => $country, - "spellcheck" => $spellcheck - ] - ), - $page, - $proxy + $nextpage = + $nextpage[count($nextpage) - 1]; + + if( + strtolower( + $this->fuckhtml + ->getTextContent( + $nextpage + ) + ) == "next" + ){ + + preg_match( + '/offset=([0-9]+)/', + $this->fuckhtml->getTextContent($nextpage["attributes"]["href"]), + $nextpage ); + + return + $this->backend->store( + json_encode( + [ + "q" => $q, + "offset" => (int)$nextpage[1], + "nsfw" => $nsfw, + "country" => $country, + "spellcheck" => $spellcheck + ] + ), + $page, + $proxy + ); + } } }