Example #1
0
 def split_code(self):
     #读取数据集dealcode,获取处理验证码图片路径
     deal_image = DealImage()
     all_code_path = self.db.downcode.find({"dealflag": 1, "splitflag": 0}, {"_id": 0, "codepath": 1})
     if all_code_path:
         all_deal_path = []
         all_code_paths = []
         for each_code in all_code_path:
             each_code_path = each_code["codepath"]
             all_code_paths.append(each_code_path)
             #读取数据集dealcode,获取处理图片路径
             each_deal_path = self.db.dealcode.find_one({"codepath": each_code_path}, {"_id": 0, "dealpath": 1})
             if each_deal_path:
                 all_deal_path.append(each_deal_path["dealpath"])
         
         for each_deal_path, each_code_path in zip(all_deal_path, all_code_paths):
             each_deal_path_temp = "../%s" % each_deal_path
             list_split_image_path = deal_image.main_split_image(each_deal_path_temp)
             if len(list_split_image_path):
                 #存入数据集splitcode,验证码路径和分割图片路径
                 exist_result = self.db.splitcode.find_one({"codepath": each_code_path})
                 if not exist_result:
                     self.db.splitcode.insert({"codepath": each_code_path, "splitpath": list_split_image_path, "time": time.ctime()})
                     #更新数据集downcode,分割标志为1
                     self.db.downcode.update({"codepath": each_code_path}, {"$set": {"splitflag": 1}})
                 else:
                     self.db.downcode.update({"codepath": each_code_path}, {"$set": {"splitflag": 0}})
Example #2
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)
Example #3
0
 def deal_split(self, save_path): 
     #处理分割图片
     deal_code = DealImage() 
     list_split_image = deal_code.main_deal_split(save_path)
     
     return list_split_image