def request(ch, method, properties, body): #print " [.] increase(%s)" % (body,) body=eval(body) response = get_html(body) print '============== Html Begin =====================' print '============== Html End =====================' #将计算结果发送回控制中心 ch.basic_publish(exchange='', routing_key=properties.reply_to, body=response) if(body['need_sleep']): sleep(sleep_time) ch.basic_ack(delivery_tag = method.delivery_tag) print '========= Complete Crawl ========='
def request(ch, method, properties, body): #print " [.] increase(%s)" % (body,) body = eval(body) response = get_html(body) print '============== Html Begin =====================' print '============== Html End =====================' #将计算结果发送回控制中心 ch.basic_publish(exchange='', routing_key=properties.reply_to, body=response) if (body['need_sleep']): sleep(sleep_time) ch.basic_ack(delivery_tag=method.delivery_tag) print '========= Complete Crawl ========='
def get_html(body): global sleep_time request=get_request(body) print 'getting' try: #response=url_opener.open(request) response=urllib2.urlopen(request,timeout=30) print response.info() html=response.read() print 'done' except Exception as e: print e print e.info() print e.read() print('Retry') sleep(10) request=get_request(body) try: response=urllib2.urlopen(request,timeout=30) html=response.read() #html=url_opener.open(request).read() except Exception as e: print e print e.info() print e.read() print('Retry') print 'get html error' return '' if('location.replace' in html): print('Redirect..') print('Try to get target') target=get_target(html) open('./keke.html','w').write(html) print target if(target==None): print(body) print 'get target error' print(html) return '' else: body['url']=target[0] html=get_html(body) #cookieJar.save() return html else: return html
def get_html(body): global sleep_time request = get_request(body) print 'getting' try: #response=url_opener.open(request) response = urllib2.urlopen(request, timeout=30) print response.info() html = response.read() print 'done' except Exception as e: print e print e.info() print e.read() print('Retry') sleep(10) request = get_request(body) try: response = urllib2.urlopen(request, timeout=30) html = response.read() #html=url_opener.open(request).read() except Exception as e: print e print e.info() print e.read() print('Retry') print 'get html error' return '' if ('location.replace' in html): print('Redirect..') print('Try to get target') target = get_target(html) open('./keke.html', 'w').write(html) print target if (target == None): print(body) print 'get target error' print(html) return '' else: body['url'] = target[0] html = get_html(body) #cookieJar.save() return html else: return html
def run10(): """ Perform a 10 minute run. """ start = time.time() Inventory.loadout(2) # loadout 2 is bars-heavy BasicTraining.basicTraining() FightBosses.fightBosses() Adventure.adventureZone() # go to latest zone Misc.inputResource() # all energy print(f'Time Machine loop for 5 minutes') while time.time() - start < 300: TimeMachine.addEnergy() TimeMachine.addMagic() print(f'sleeping for 30 seconds') sleep(30) Inventory.loadout(1) BasicTraining.basicTraining() Misc.reclaimAll() # reclaim energy and magic from TM print(f'Main loop until 10 minutes') mainStart = time.time() pushAdventure = False while time.time() - start < 570: # push to new adventure zone if time.time() - mainStart > 120 and not pushAdventure: Adventure.adventureZone() pushAdventure = True print(f'sleeping 30 seconds') sleep(30) # fight bosses FightBosses.nuke() for _ in range(5): FightBosses.fightBoss() # augments Misc.inputResource(amount='quarter', idle=True) for _ in range(3): Augmentation.augmentation(aug=4) Augmentation.augmentation(aug=4, upgrade=True) # blood magic BloodMagic.addMagic(cap=True) BloodMagic.addMagic(magic=2, cap=True) BloodMagic.addMagic(magic=3, cap=True) MoneyPit.moneyPit() Navigation.menu('rebirth') while time.time() - start < 600: sleep(1) Rebirth.rebirth()
def run5(): """ Perform a 5 minute run.""" start = time.time() Inventory.loadout(2) # loadout 2 is bars-heavy BasicTraining.basicTraining() FightBosses.nuke() sleep(3) Adventure.adventureZone() # go to latest zone Misc.inputResource() # all energy print(f'Time Machine loop for 2:30 minutes') inv1 = False lastZone = False loopCounter = 0 while time.time() - start < 150: loopCounter += 1 TimeMachine.addEnergy() TimeMachine.addMagic() if time.time() - start > 120 and not inv1: Inventory.loadout(1) BasicTraining.basicTraining() inv1 = True if loopCounter == 10: Adventure.itopodFarm() # if not lastZone: # Adventure.adventureZone() # lastZone = True Misc.reclaimAll() # reclaim energy and magic from TM print(f'Main loop until 5 minutes') mainStart = time.time() pushAdventure = False loopCounter = 0 while time.time() - start < 280: loopCounter += 1 # push to new adventure zone # if time.time() - mainStart > 30 and not pushAdventure: # Adventure.adventureZone() # pushAdventure = True # fight bosses if loopCounter == 2: Adventure.itopodFarm() FightBosses.nuke() for _ in range(5): FightBosses.fightBoss() # augments Misc.inputResource(amount='quarter', idle=True) for _ in range(3): Augmentation.augmentation(aug=2) Augmentation.augmentation(aug=2, upgrade=True) # blood magic # BloodMagic.addMagic(cap=True) # BloodMagic.addMagic(magic=2, cap=True) # BloodMagic.addMagic(magic=3, cap=True) BloodMagic.addMagic(magic=3, cap=True) print(f'sleeping 15 seconds') sleep(15) MoneyPit.moneyPit() FightBosses.nuke() FightBosses.fightBoss() print('getting exp') # Statistics.screenshot('rebirth.png') expStart = time.time() exp = Statistics.getEXP() expEnd = time.time() print(f'time: {round(expStart - expEnd, 3)}') print('waiting for time') while time.time() - start < 300: sleep(1) Navigation.menu('fightBoss') click(*coords.STOP) # stop fighting bosses Navigation.menu('rebirth') Rebirth.rebirth() return exp
def run3(): """ Perform a 3 minute run. """ start = time.time() Inventory.loadout(2) FightBosses.nuke() sleep(5) for i in range(3): FightBosses.fightBoss() Adventure.adventureZone('mega') sleep(5) Adventure.itopodFarm() Misc.inputResource() bm = False done = False wandoos = False adv = False while time.time() - start < 165: Misc.inputResource(amount='quarter', idle=True) if wandoos: Wandoos.addMagic() Wandoos.addEnergy() TimeMachine.addEnergy() TimeMachine.addMagic() Augmentation.augmentation(aug=4) Augmentation.augmentation(aug=4, upgrade=True) Wandoos.addEnergy() if time.time() - start > 60 and not done: Inventory.loadout(1) GoldDiggers.wandoosDigger() Adventure.adventureZone() sleep(5) Adventure.itopodFarm() bm = True if bm and not done: Misc.reclaimMagic() BloodMagic.addMagic(magic=5, cap=True) BloodMagic.addMagic(magic=4, cap=True) BloodMagic.addMagic(magic=3, cap=True) BloodMagic.addMagic(magic=2, cap=True) BloodMagic.addMagic(magic=1, cap=True) done = True wandoos = True FightBosses.nuke() FightBosses.fightBoss() GoldDiggers.clearActive() GoldDiggers.statDigger() MoneyPit.moneyPit() FightBosses.nuke() for i in range(4): FightBosses.fightBoss() sleep(1) # Navigation.menu('rebirth') while time.time() - start < 175: sleep(0.1) exp = Statistics.getEXP() # Statistics.screenshot('rebirth.png') Navigation.menu('fightBoss') click(*coords.STOP) # stop fighting Navigation.menu('rebirth') while time.time() - start < 180: sleep(0.1) Rebirth.rebirth() return exp
def run7(): """ Perform a 7 minute run.""" start = time.time() Inventory.loadout(2) # loadout 2 is bars-heavy BasicTraining.basicTraining() FightBosses.fightBosses() Adventure.adventureZone() # go to latest zone Misc.inputResource() # all energy print(f'Time Machine loop for 4 minutes') inv1 = False lastZone = False while time.time() - start < 180: TimeMachine.addEnergy() TimeMachine.addMagic() if time.time() - start > 180 and not inv1: Inventory.loadout(1) BasicTraining.basicTraining() inv1 = True if not lastZone: Adventure.adventureZone() lastZone = True startTime = time.time() Misc.reclaimAll() # reclaim energy and magic from TM print(f'Main loop until 7 minutes') mainStart = time.time() pushAdventure = False while time.time() - start < 390: # push to new adventure zone if time.time() - mainStart > 120 and not pushAdventure: Adventure.adventureZone() pushAdventure = True # fight bosses FightBosses.nuke() for _ in range(5): FightBosses.fightBoss() # augments Misc.inputResource(amount='quarter', idle=True) for _ in range(3): Augmentation.augmentation(aug=3) Augmentation.augmentation(aug=3, upgrade=True) # blood magic BloodMagic.addMagic(cap=True) BloodMagic.addMagic(magic=2, cap=True) BloodMagic.addMagic(magic=3, cap=True) print(f'sleeping 30 seconds') sleep(30) MoneyPit.moneyPit() FightBosses.nuke() FightBosses.fightBoss() print('waiting for time') # Statistics.screenshot('rebirth.png') while time.time() - start < 420: sleep(1) click(*coords.STOP) # stop fighting Navigation.menu('rebirth') Rebirth.rebirth()