from _clickjob import * custlist = ["The Icons_EN", "The Icons_ZH"] db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4') def reset(cust): #USING CUSTKW2 AND CUSTURL2 BECAUSE THE FIRST ONE IS MESSING UP. REVERT BACK LATER. k=db.query('select * from seo.seo_nton_custkw2 where cust="' + cust + '" and disused=0') u=db.query('select * from seo.seo_nton_custurl2 where cust="' + cust + '" and disused=0') #TAG ABOVE AND UNTAG BELOW FOR DEBUG #ds=hhhdb.query('select * from seo.seo_articles where cust=') kwd=[] urld=[] for i in k: kwd.append(i['kw'].replace('\xa0',' ')) for i in u: urld.append(i['url'].replace('\xa0',' ')) random.shuffle(kwd) random.shuffle(urld) return [kwd,urld,c] runcount=0 while True: try: data=[] cust = custlist print("Gathering data...") for c in cust: data.append(reset(c)) print('Data collected') dataok = 1 print(len(data)) except: dataok = 0 print("Error while collecting data.") if dataok == 1: for i in range(10): print("Run " + str(runcount+1)) target = random.choice(data) # START HERE print(target) target_kw = random.choice(target[0]) print(target_kw) statuscode = execute(target[1], target_kw, target[2]) # target[1] is URL list if statuscode == 444: print("Completed ", runcount, " times before being caught") time.sleep(300) else: runcount+=1 else: time.sleep(60)