Parcourir la source

detect qwant captcha

lolcat il y a 4 mois
Parent
commit
fdd44dd373
1 fichiers modifiés avec 11 ajouts et 0 suppressions
  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){