diff options
author | lolcat <will@lolcat.ca> | 2024-06-25 18:05:43 -0400 |
---|---|---|
committer | lolcat <will@lolcat.ca> | 2024-06-25 18:05:43 -0400 |
commit | 77931f3ee9b2a51d83b05752b3d98638b30cae38 (patch) | |
tree | 66b41aab5606c9ed9b5387afb6fc2f2edba9fad5 | |
parent | 640d1d1953669115dc67dfdaf86998401a9bfac4 (diff) |
brave error handling
-rw-r--r-- | scraper/brave.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/scraper/brave.php b/scraper/brave.php index 3e6c449..fd4c46e 100644 --- a/scraper/brave.php +++ b/scraper/brave.php @@ -422,6 +422,19 @@ class brave{ 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"]; /* |