Explorar o código

update:删除验证码识别结果字符串转大写;部分问题修复

dongzhaorui %!s(int64=2) %!d(string=hai) anos
pai
achega
d1296a6b25
Modificáronse 1 ficheiros con 4 adicións e 9 borrados
  1. 4 9
      FworkSpider/untils/get_imgcode.py

+ 4 - 9
FworkSpider/untils/get_imgcode.py

@@ -55,7 +55,7 @@ def _arithmetic_captcha(file):
 def _get_click_verify_captcha(file):
     """点触式验证码"""
     url = "http://123.57.163.80:2119/v1/images/verify_det"
-    files = _pack_file(file)
+    files = {"image_content": v for k, v in _pack_file(file).items()}
     r = requests.post(url, headers=headers, files=files, stream=True, timeout=10)
     return r.json()
 
@@ -76,10 +76,7 @@ def chaojiying_platform(file, pic_type: int):
 
     pic_type,详情查询地址: https://www.chaojiying.com/price.html
     """
-    with open(file, 'rb') as f:
-        image_bytes = f.read()
-    files = {'file': image_bytes}
-
+    files = _pack_file(file)
     url = f"http://123.57.163.80:2119/v1/images/discern?pic_type={pic_type}"
     headers = {'accept': 'application/json'}
     data = {
@@ -92,13 +89,12 @@ def chaojiying_platform(file, pic_type: int):
     }
     response = requests.post(url, headers=headers, data=data, files=files, timeout=10)
     json_resp = response.json()
-    # print(json_resp)
     '''code 返回0时,打码平台正常返回数据'''
     pic_str = json_resp["r"]["pic_str"]
     pic_id = json_resp["r"]["pic_id"]
-    print("pic_id >>", pic_id)
     if 0 == json_resp["code"]:
-        return pic_str
+        return pic_str, pic_id
+    return None, pic_id
 
 
 def chaojiying_report(pic_id: str):
@@ -121,7 +117,6 @@ def chaojiying_report(pic_id: str):
     回调成功:{'msg': 'OK', 'code': 0}  
     此接口不能随便调用!程序逻辑里要这样判断: 如果 识别结果是错的 再调用 报错返分 接口。 如果没有这个判断或是无法判断,就不要调用!
     '''
-    # print(response.json())
     return response.json()