BEG = BEGING_PAGE END = BEGING_PAGE + deltaX while x < TT.GV_THEAD_COUNT: tn = threading.Thread(target=TT.downloadPage,args=(int(END),x+1,begURL,int(BEG),)) t.append(tn) x += 1 BEG += deltaX END += deltaX #启动线程 for item in t: item.setDaemon(True) item.start() #循环处理数据 sum,mstr = TT.pocessDataList(TT.GV_THEAD_COUNT,begURL) #===================================全部处理完毕,储存至文件====================================== now = datetime.datetime.now() now.strftime('%Y-%m-%d %H:%M:%S') last_data_source = {'sum':sum,'time':now} TT.savetofile(mstr,'C:\\ktieba\\result.txt') f = open('C:\\ktieba\\result_add','wb') pickle.dump(last_data_source, f,2) f.close() time2 = time.time() tc = time2 - time1 print('>>>>>抓取完毕!耗时:',str(tc),'秒\n>>>>>共抓取【',sum,'】条数据\n>>>>>结果已经保存至','C:\\ktieba\\result.txt') #===================================向服务器回传任务结果====================================== FILESENDCMD = str(TZDS.JOBTRANSFER)+",Ready to send" s.sendall(FILESENDCMD.encode("utf-8"))
BEG = 0 END = deltaX while x < TT.GV_THEAD_COUNT: tn = threading.Thread(target=TT.downloadPage,args=(int(END),x+1,begURL,int(BEG),)) t.append(tn) x += 1 BEG += deltaX END += deltaX #启动线程 for item in t: item.setDaemon(True) item.start() #循环处理数据 sum,mstr = TT.pocessDataList(TT.GV_THEAD_COUNT,begURL,tieba_name) #===================================全部处理完毕,储存至文件====================================== now = datetime.datetime.now() now.strftime('%Y-%m-%d %H:%M:%S') last_data_source = {'sum':sum,'time':now} f = open('C:\\ktieba\\result_add','wb') pickle.dump(last_data_source, f,2) f.close() time2 = time.time() tc = time2 - time1 print('>>>>>抓取完毕!耗时:',str(tc),'秒\n>>>>>共抓取【',sum,'】条数据\n>>>>>结果已经保存至','C:\\ktieba\\result.txt') #=============邮件提醒=================== #计算耗时 totalseconds = tc days = int(tc/86400)