icons.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from _clickjob import *
  2. custlist = ["The Icons_EN", "The Icons_ZH"]
  3. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  4. def reset(cust): #USING CUSTKW2 AND CUSTURL2 BECAUSE THE FIRST ONE IS MESSING UP. REVERT BACK LATER.
  5. k=db.query('select * from seo.seo_nton_custkw2 where cust="' + cust + '" and disused=0')
  6. u=db.query('select * from seo.seo_nton_custurl2 where cust="' + cust + '" and disused=0')
  7. #TAG ABOVE AND UNTAG BELOW FOR DEBUG
  8. #ds=hhhdb.query('select * from seo.seo_articles where cust=')
  9. kwd=[]
  10. urld=[]
  11. for i in k:
  12. kwd.append(i['kw'].replace('\xa0',' '))
  13. for i in u:
  14. urld.append(i['url'].replace('\xa0',' '))
  15. random.shuffle(kwd)
  16. random.shuffle(urld)
  17. return [kwd,urld,c]
  18. runcount=0
  19. while True:
  20. try:
  21. data=[]
  22. cust = custlist
  23. print("Gathering data...")
  24. for c in cust:
  25. data.append(reset(c))
  26. print('Data collected')
  27. dataok = 1
  28. print(len(data))
  29. except:
  30. dataok = 0
  31. print("Error while collecting data.")
  32. if dataok == 1:
  33. for i in range(10):
  34. print("Run " + str(runcount+1))
  35. target = random.choice(data) # START HERE
  36. print(target)
  37. target_kw = random.choice(target[0])
  38. print(target_kw)
  39. statuscode = execute(target[1], target_kw, target[2]) # target[1] is URL list
  40. if statuscode == 444:
  41. print("Completed ", runcount, " times before being caught")
  42. time.sleep(300)
  43. else:
  44. runcount+=1
  45. else:
  46. time.sleep(60)