def find_site(self): url_temp_list = [] for ip_info in self.ip_info_list: for port_info in ip_info["port_info"]: curr_ip = ip_info["ip"] port_id = port_info["port_id"] if port_id == 80: url_temp = "http://{}".format(curr_ip) url_temp_list.append(url_temp) continue if port_id == 443: url_temp = "https://{}".format(curr_ip) url_temp_list.append(url_temp) continue url_temp1 = "http://{}:{}".format(curr_ip, port_id) url_temp2 = "https://{}:{}".format(curr_ip, port_id) url_temp_list.append(url_temp1) url_temp_list.append(url_temp2) check_map = services.check_http(url_temp_list) # 去除https和http相同的 alive_site = [] for x in check_map: if x.startswith("https://"): alive_site.append(x) elif x.startswith("http://"): x_temp = "https://" + x[7:] if x_temp not in check_map: alive_site.append(x) self.site_list.extend(alive_site)
def run(self): url_temp_list = set(self._build()) start_time = time.time() logger.info("start check_http {}".format(len(url_temp_list))) check_map = services.check_http(url_temp_list) # 去除https和http相同的 alive_site = [] for x in check_map: if x.startswith("https://"): alive_site.append(x) elif x.startswith("http://"): x_temp = "https://" + x[7:] if x_temp not in check_map: alive_site.append(x) elapse = time.time() - start_time logger.info("end check_http result {}, elapse {}".format(len(alive_site), elapse)) return alive_site