def __init__(self, start_date=None, *args, **kwargs): super(cn_proxy, self).__init__(*args, **kwargs) self.start_date = None if start_date is None: self.start_date = (datetime.datetime.now() + datetime.timedelta(days=-1)).strftime('%Y-%m-%d %H:%M:%S') else: self.start_date = "%s-%s-%s" % (start_date[0:4], start_date[4:6], start_date[6:8]) script_dir = self.get_script_dir() config = FileUtility.load_json_config('%s/../../../../conf/proxy_crawler.config.json' % script_dir) timestamp = time.strftime('%Y-%m-%d_%H:%M:%S') self._logger = get_logger("%s/../../../../log/%s.%s.log" % (script_dir, self.name, timestamp), config['log_level'])
this_func_name = sys._getframe().f_code.co_name self.logger.debug("%s(): start ..." % this_func_name) if self.login(): self.vip_check_in() self.finance_check_in() self.driver.quit() self.logger.debug("%s(): end ..." % this_func_name) return def get_script_dir(): return os.path.dirname(os.path.realpath(__file__)) if __name__ == '__main__': this_func_name = __name__ script_dir = get_script_dir() config = FileUtility.load_json_config('%s/../conf/check_in.config.json' % script_dir) timestamp = time.strftime('%Y-%m-%d_%H:%M:%S') logger = get_logger("%s/../log/jd.%s.log" % (script_dir, timestamp), config['log_level']) logger.debug( "%s(): ****************************************************************************************************" % this_func_name) for item in config['jd']: jd = JD(logger, item['user_name'], item['password']) jd.run()
else: continue l.append(result[0]) logger.debug("%s(): index: %d\tresponse delay: %f" % (this_func_name, index, result[0])) logger.debug("%s(): response delay records\t%s" % (this_func_name, l)) if len(l) > 0: average = round(sum(l) / len(l), 1) logger.debug("%s(): response delay average\t%f" % (this_func_name, average)) return average return if __name__ == '__main__': logger = get_logger('/tmp/http_tools.log') logger.info( "****************************************************************************************************" ) logger.info("start ...") ip = "205.252.220.20" result = inquire_ip_location(logger, ip) logger.info("%s\t%s" % (ip, result)) test_port_open(logger, '45.32.36.87', 312888) test_port_open(logger, '45.32.36.87', 8888) # url = "https://www.baidu.com/" url = "http://mindcache.io/" # url = "https://twitter.com/"