Ejemplo n.º 1
0
 def deal_code(self):
     #读取数据库downcode,获取验证码路径
     deal_image = DealImage()
     all_down_code = self.db.downcode.find({"dealflag": 0}, {"_id": 0, "codepath": 1})
     if all_down_code:
         for code_path in all_down_code:
             code_path_temp = code_path["codepath"]
             #预处理图片
             code_path_temps = "../%s" % code_path_temp
             save_path = deal_image.main_deal_image(code_path_temps)
             if len(save_path):
                 #存入数据库dealcode,验证码路径和验证码处理后路径
                 exist_result = self.db.dealcode.find_one({"codepath": code_path_temp})
                 if not exist_result:
                     self.db.dealcode.insert({"codepath": code_path_temp, "dealpath": save_path, "time": time.ctime()})
                     self.db.downcode.update({"codepath": code_path_temp}, {"$set": {"dealflag": 1}})
                 
             time.sleep(1)