mirror of
https://git.lolcat.ca/lolcat/4get.git
synced 2024-11-14 03:49:48 +01:00
qwant gibberish check
This commit is contained in:
parent
81dc93802c
commit
f2eb164d40
1 changed files with 23 additions and 0 deletions
|
@ -453,6 +453,8 @@ class qwant{
|
||||||
switch($item["type"]){ // ignores ads
|
switch($item["type"]){ // ignores ads
|
||||||
|
|
||||||
case "web":
|
case "web":
|
||||||
|
|
||||||
|
$first_iteration = true;
|
||||||
foreach($item["items"] as $result){
|
foreach($item["items"] as $result){
|
||||||
|
|
||||||
if(isset($result["thumbnailUrl"])){
|
if(isset($result["thumbnailUrl"])){
|
||||||
|
@ -483,6 +485,25 @@ class qwant{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// detect gibberish results
|
||||||
|
if(
|
||||||
|
$first_iteration &&
|
||||||
|
preg_match(
|
||||||
|
"/^" .
|
||||||
|
preg_quote(
|
||||||
|
$this->trimdots(
|
||||||
|
$result["source"]
|
||||||
|
),
|
||||||
|
"/"
|
||||||
|
) .
|
||||||
|
"/",
|
||||||
|
$result["url"]
|
||||||
|
) !== 1
|
||||||
|
){
|
||||||
|
|
||||||
|
throw new Exception("Qwant returned gibberish results");
|
||||||
|
}
|
||||||
|
|
||||||
$out["web"][] = [
|
$out["web"][] = [
|
||||||
"title" => $this->trimdots($result["title"]),
|
"title" => $this->trimdots($result["title"]),
|
||||||
"description" => $this->trimdots($result["desc"]),
|
"description" => $this->trimdots($result["desc"]),
|
||||||
|
@ -493,6 +514,8 @@ class qwant{
|
||||||
"sublink" => $sublinks,
|
"sublink" => $sublinks,
|
||||||
"table" => []
|
"table" => []
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$first_iteration = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue