Explorar el Código

detect qwant captcha

lolcat hace 4 meses
padre
commit
fdd44dd373
Se han modificado 1 ficheros con 11 adiciones y 0 borrados
  1. 11 0
      scraper/qwant.php

+ 11 - 0
scraper/qwant.php

@@ -905,6 +905,17 @@ class qwant{
 			
 			throw new Exception("Qwant returned an API error");
 		}
+		
+		if(
+			isset($json["url"]) &&
+			preg_match(
+				'/captcha/i',
+				$json["url"]
+			)
+		){
+			
+			throw new Exception("Qwant returned a captcha redirect");
+		}
 	}
 	
 	private function limitstrlen($text){