12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 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):
- k=db.query('select * from seo.seo_nton_custkw where cust="' + cust + '"')
- u=db.query('select * from seo.seo_nton_custurl where cust="' + cust + '"')
- #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
- 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)
|