def crawl_mkdir(self): dirroot = '/estar/newhuike2/1/' tm_s, tm_millisecond = crawlerfun.get_timestamp(ifmillisecond = 1) dirsmall = 'iask' + str(self.ipnum) + '.' + str(1) + '.' + str(tm_s) + '.' + str(tm_millisecond) + '/' self._dir = dirroot + '_' + dirsmall self.dir = dirroot + dirsmall return self._dir, self.dir
def baijiahao_mkdir(self): # 建立目录 /estar/newhuike2/1/_iask1553618820.1.1.1 # _iask[ip数字].[线程号].[时间戳].[毫秒时间戳 dirroot = '/estar/newhuike2/1/' # t = time.time() # tm = int(time.time()) # tm_millisecond = int(tm * 1000 ) % 1000 tm_s, tm_millisecond = crawlerfun.get_timestamp(ifmillisecond=1) # ip = '183.131.246.178' # ip_num = socket.ntohl(struct.unpack("I", socket.inet_aton(str(self.ip)))[0]) # ip_num = crawlerfun.ip2num(self.ip) # dirsmall = 'iask'+ str(tm) + '.'+str(tm_millisecond)+'.'+str(self.index)+'.'+str(ip_num)+'/' dirsmall = 'iask' + str(self.ipnum) + '.' + str( self.index) + '.' + str(tm_s) + '.' + str(tm_millisecond) + '/' self._dir = dirroot + '_' + dirsmall self.dir = dirroot + dirsmall # 不建立等有了新文章再建立 # os.mkdir(self._dir) return self._dir, self.dir