forked from lolcat/4get
qwant gibberish check fix
This commit is contained in:
parent
a2c595b6f2
commit
b492ef2329
|
@ -360,7 +360,17 @@ class qwant{
|
||||||
return $out;
|
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"])){
|
if(!isset($json["data"]["result"]["items"]["mainline"])){
|
||||||
|
@ -488,17 +498,7 @@ class qwant{
|
||||||
// detect gibberish results
|
// detect gibberish results
|
||||||
if(
|
if(
|
||||||
$first_iteration &&
|
$first_iteration &&
|
||||||
preg_match(
|
!isset($result["urlPingSuffix"])
|
||||||
"/^" .
|
|
||||||
preg_quote(
|
|
||||||
$this->trimdots(
|
|
||||||
$result["source"]
|
|
||||||
),
|
|
||||||
"/"
|
|
||||||
) .
|
|
||||||
"/",
|
|
||||||
$result["url"]
|
|
||||||
) !== 1
|
|
||||||
){
|
){
|
||||||
|
|
||||||
throw new Exception("Qwant returned gibberish results");
|
throw new Exception("Qwant returned gibberish results");
|
||||||
|
|
Loading…
Reference in New Issue