Explorar o código

duckduckgo images nsfw fix

lolcat hai 1 ano
pai
achega
49ddd1a216
Modificáronse 2 ficheiros con 9 adicións e 5 borrados
  1. 8 3
      scraper/ddg.php
  2. 1 2
      scraper/yandex.php

+ 8 - 3
scraper/ddg.php

@@ -285,6 +285,7 @@ class ddg{
 							"display" => "NSFW",
 							"option" => [
 								"yes" => "Yes",
+								"maybe" => "Maybe",
 								"no" => "No"
 							]
 						],
@@ -1345,7 +1346,7 @@ class ddg{
 				$get_filters["iaf"] = $filters;
 			}
 			
-			$nsfw = $get["nsfw"] == "yes" ? "-2" : "-1";
+			$nsfw = $get["nsfw"] == "yes" ? "-1" : "1";
 			$get_filters["kp"] = $nsfw;
 			
 			try{
@@ -1498,8 +1499,12 @@ class ddg{
 				"ia" => "videos"
 			];
 			
-			$nsfw = $get["nsfw"] == "yes" ? "-2" : "-1";
-			$get_filters["kp"] = $nsfw;
+			switch($get["nsfw"]){
+				
+				case "yes": $nsfw = "-2"; break;
+				case "maybe": $nsfw = "-1"; break;
+				case "no": $nsfw = "1"; break;
+			}
 			
 			$filters = [];
 			

+ 1 - 2
scraper/yandex.php

@@ -37,7 +37,7 @@ class yandex{
 			"Accept-Encoding: gzip",
 			"Accept-Language: en-US,en;q=0.5",
 			"DNT: 1",
-			"Cookie: yp=1716337604.sp.family%3A{$nsfw}#1685406411.szm.1:1920x1080:1920x999",
+			"Cookie: yp=" . (time() - 4000033) . ".szm.1:1920x1080:876x1000#" . time() . ".sp.family:" . $nsfw,
 			"Referer: https://yandex.com/images/search",
 			"Connection: keep-alive",
 			"Upgrade-Insecure-Requests: 1",
@@ -668,7 +668,6 @@ class yandex{
 		foreach($json["blocks"] as $block){
 			
 			$html .= $block["html"];
-			
 			// get next page
 			if(
 				isset($block["params"]["nextPageUrl"]) &&