summaryrefslogtreecommitdiff
path: root/scraper
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2024-05-30 19:13:47 -0400
committerlolcat <will@lolcat.ca>2024-05-30 19:13:47 -0400
commitb492ef2329ef918b0b40f3090b4bdc3681e3fd09 (patch)
treee908e1e1400c3a6dfc13a88e237685c79d7aec3b /scraper
parenta2c595b6f2b543f7b1e21420aa23093260481946 (diff)
qwant gibberish check fix
Diffstat (limited to 'scraper')
-rw-r--r--scraper/qwant.php24
1 files changed, 12 insertions, 12 deletions
diff --git a/scraper/qwant.php b/scraper/qwant.php
index f914e15..48ecd85 100644
--- a/scraper/qwant.php
+++ b/scraper/qwant.php
@@ -360,7 +360,17 @@ class qwant{
return $out;
}
- throw new Exception("Server returned an error code: " . $json["data"]["error_code"]);
+ if(isset($json["data"]["error_code"])){
+
+ switch($json["data"]["error_code"]){
+
+ case 27:
+ throw new Exception("Qwant returned a captcha");
+ break;
+ }
+ }
+
+ throw new Exception("Qwant returned an error code: " . $json["data"]["error_code"]);
}
if(!isset($json["data"]["result"]["items"]["mainline"])){
@@ -488,17 +498,7 @@ class qwant{
// detect gibberish results
if(
$first_iteration &&
- preg_match(
- "/^" .
- preg_quote(
- $this->trimdots(
- $result["source"]
- ),
- "/"
- ) .
- "/",
- $result["url"]
- ) !== 1
+ !isset($result["urlPingSuffix"])
){
throw new Exception("Qwant returned gibberish results");