소스 검색

handle captcha on coc coc

lolcat 11 달 전
부모
커밋
8a0a8359a8
1개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      scraper/coccoc.php

+ 8 - 0
scraper/coccoc.php

@@ -165,6 +165,14 @@ class coccoc{
 			throw new Exception("Failed to decode JSON");
 		}
 		
+		if(
+			isset($html["captcha"]) &&
+			(int)$html["captcha"] === 1
+		){
+			
+			throw new Exception("Coc Coc returned a Captcha");
+		}
+		
 		if(!isset($html["search"]["search_results"])){
 			
 			throw new Exception("Coc Coc did not return a search_results object");