diff options
author | gesang <gesang@itinerariummentis.org> | 2024-06-26 09:10:46 +0000 |
---|---|---|
committer | gesang <gesang@itinerariummentis.org> | 2024-06-26 09:10:46 +0000 |
commit | 40752f5eb2b23889f444cdc6cf10c0eadd4fa11d (patch) | |
tree | 7a617098e9d95e74b694b67fb66b27a47f1bdcb2 /scraper | |
parent | 121ab66eecd5798b10461274b8f210f1caa3009a (diff) | |
parent | 77931f3ee9b2a51d83b05752b3d98638b30cae38 (diff) |
Merge branch 'master' of https://git.lolcat.ca/lolcat/4get
Diffstat (limited to 'scraper')
-rw-r--r-- | scraper/brave.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/scraper/brave.php b/scraper/brave.php index 8be55ac..fd4c46e 100644 --- a/scraper/brave.php +++ b/scraper/brave.php @@ -295,6 +295,7 @@ class brave{ $html = fread($handle, filesize("scraper/brave.html")); fclose($handle); */ + try{ $html = $this->get( @@ -406,9 +407,9 @@ class brave{ if(!isset($grep[1])){ - throw new Exception("Could not get data JS"); + throw new Exception("Could not grep JavaScript object"); } - + $data = $this->fuckhtml ->parseJsObject( @@ -416,6 +417,24 @@ class brave{ ); unset($grep); + if($data === null){ + + throw new Exception("Failed to decode JavaScript object"); + } + + if( + isset($data[2]["data"]["title"]) && + stripos($data[2]["data"]["title"], "PoW Captcha") !== false + ){ + + throw new Exception("Brave returned a PoW captcha"); + } + + if(!isset($data[1]["data"]["body"]["response"])){ + + throw new Exception("Brave did not return a result object"); + } + $data = $data[1]["data"]["body"]["response"]; /* |