class Report: def __init__(self): # get the logger self.logger = Logger(log_path=Config.logdir+'/Report.log', log_level='debug', log_name='Report') self.logger.debug("logger test ok") # init sqlite self.sqlite = Sqlite() self.cap = Capture() self.logger.debug("init over") def get_available_name(self): try: result = self.sqlite.get_available_yuming_infos() return result except Exception,ex: self.logger.error("get_available_name error:%s" %(ex)) return []
class Report: def __init__(self): # get the logger self.logger = Logger(log_path=Config.logdir + '/Report.log', log_level='debug', log_name='Report') self.logger.debug("logger test ok") # init sqlite self.sqlite = Sqlite() self.cap = Capture() self.logger.debug("init over") def get_available_name(self): try: result = self.sqlite.get_available_yuming_infos() return result except Exception, ex: self.logger.error("get_available_name error:%s" % (ex)) return []
try_times += 1 self.logger.error("[http_get] try_times:%s." %(try_times)) if try_times >= maxTryTimes: self.logger.error("http_get error: %s" %(ex)) return None continue return req.read() return None if __name__ == "__main__": logger.debug("main begin") cap = Capture() cap.do_capture() # test generate ''' cnt = 0 for one in cap.generate_domain_names(): #logger.debug("name: %s, cnt = %s" %(one, cnt)) cnt += 1 print "name: %s, cnt = %s" %(one, cnt) ''' logger.debug("main over")
try_times += 1 self.logger.error("[http_get] try_times:%s." % (try_times)) if try_times >= maxTryTimes: self.logger.error("http_get error: %s" % (ex)) return None continue return req.read() return None if __name__ == "__main__": logger.debug("main begin") cap = Capture() cap.do_capture() # test generate ''' cnt = 0 for one in cap.generate_domain_names(): #logger.debug("name: %s, cnt = %s" %(one, cnt)) cnt += 1 print "name: %s, cnt = %s" %(one, cnt) ''' logger.debug("main over")
log.debug("dump index %s " % repr(nodes)) proxys = [] if len(nodes) > 0: proxys = _getIpAndPort(nodes) return proxys # for items in infos: # log.debug("items %s " % repr(items)) except Exception as e: log.error("parser tree error %s" % repr(e)) return [] def _decode(s, codeset='utf-8'): g = s.decode(codeset) return g def _encode(s, codeset='utf-8'): g = s.encode(codeset) return g if __name__ == "__main__": headers = { 'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6' } r = requests.get('https://www.xicidaili.com/nn/', headers=headers) log.debug("status code %d" % (r.status_code)) _proxys = _parsing(r.text)