qwant fix

This commit is contained in:
2026-06-14 15:10:55 -04:00
parent b28767d8f0
commit d54e4dfcdd

View File

@@ -217,15 +217,19 @@ class qwant{
$headers = [ $headers = [
"User-Agent: " . config::USER_AGENT, "User-Agent: " . config::USER_AGENT,
"Accept: application/json, text/plain, */*", "Accept: application/json, text/plain, */*",
"Accept-Language: en-US,en;q=0.5", "Accept-Language: en-US,en;q=0.9",
"Accept-Encoding: gzip", "Accept-Encoding: gzip, deflate, br, zstd",
"DNT: 1",
"Connection: keep-alive",
"Origin: https://www.qwant.com",
"Referer: https://www.qwant.com/", "Referer: https://www.qwant.com/",
"Origin: https://www.qwant.com",
"DNT: 1",
"Sec-GPC: 1",
"Connection: keep-alive",
"Sec-Fetch-Dest: empty", "Sec-Fetch-Dest: empty",
"Sec-Fetch-Mode: cors", "Sec-Fetch-Mode: cors",
"Sec-Fetch-Site: same-site", "Sec-Fetch-Site: same-site",
"Priority: u=4",
"Pragma: no-cache",
"Cache-Control: no-cache",
"TE: trailers" "TE: trailers"
]; ];
@@ -297,7 +301,8 @@ class qwant{
"device" => "desktop", "device" => "desktop",
"tgp" => 3, "tgp" => 3,
"safesearch" => 0, "safesearch" => 0,
"displayed" => "true" "displayed" => "true",
"llm" => "false"
]; ];
switch($get["nsfw"]){ switch($get["nsfw"]){
@@ -316,7 +321,7 @@ class qwant{
$json = $json =
$this->get( $this->get(
$proxy, $proxy,
"https://fdn.qwant.com/v3/search/web", "https://api.qwant.com/v3/search/web",
$params $params
); );
@@ -353,6 +358,8 @@ class qwant{
"related" => [] "related" => []
]; ];
$this->detect_errors($json);
if( if(
$json["status"] != "success" && $json["status"] != "success" &&
$json["data"]["error_code"] === 5 $json["data"]["error_code"] === 5
@@ -362,8 +369,6 @@ class qwant{
return $out; return $out;
} }
$this->detect_errors($json);
if(!isset($json["data"]["result"]["items"]["mainline"])){ if(!isset($json["data"]["result"]["items"]["mainline"])){
throw new Exception("Server did not return a result object"); throw new Exception("Server did not return a result object");