def __init__(self, poolsize=1000, logger=None): self.__connect_pool = Queue.Queue(maxsize=poolsize) #连接池 self.connectTool = connecttool.ConnectTool() self.logger = logger
def __init__(self, poolsize=10): self.__connect_pool = Queue.Queue(maxsize=poolsize) #连接池 # 启用代理 self.connectTool = connecttool.ConnectTool() self.logger = initLog('/root/log/baozhang/logs/connectpool.log', 2, False, 'connectpool')
result['title'] = '' return result def getcode(url): import chardet import urllib result = 'unknow' try: data1 = urllib.urlopen(url).read() chardit1 = chardet.detect(data1) result = chardit1['encoding'] except Exception, e: print e return result if __name__ == "__main__": import connecttool a = connecttool.ConnectTool() head, keywords = a.getHTML('http://www.biquge.com', way='GET', params={}, times=1) k = getwebinfo(keywords) print k['keywords'], k['title']
def __init__(self, poolsize=10): self.__connect_pool = Queue.Queue(maxsize=poolsize) #连接池 self.connectTool = connecttool.ConnectTool()
def __init__(self, poolsize=10): self.__connect_pool = Queue.Queue(maxsize=poolsize) #连接池 self.connectTool = connecttool.ConnectTool() self.logger = initLog('logs/connectpool.log', 2, True, 'connectpool')