run_sheet_local.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import sys
  2. import codecs
  3. import traceback
  4. import re
  5. import pandas as pd
  6. import random
  7. import os
  8. import redis
  9. import time
  10. import fire
  11. import dataset
  12. import pymysql
  13. pymysql.install_as_MySQLdb()
  14. def run_once():
  15. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  16. lst = ['倉儲管理 神助移動貨架','倉儲管理 神助貨架','倉儲 管理']
  17. # cursor = db.query('select term, domain from seo.selected_kw where client="仁本"')
  18. # for c in cursor:
  19. # lst.append([c['term'], c['domain']])
  20. obj = random.choice(lst)
  21. kw = obj
  22. domain = 'jiatetea.tw'
  23. print(kw, domain)
  24. os.chdir('C:\/Users\/s1301\/PycharmProjects\/kw_tools\/INNNews')
  25. intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}"')
  26. print('執行完成genetal_clickbot')
  27. if intval == -1:
  28. print('-1')
  29. sys.exit()
  30. db.close()
  31. def run_specific():
  32. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  33. # db_local = dataset.connect('mysql://root:jondae350@localhost/ig_tags')
  34. lst = []
  35. cursor = db.query('select term, domain from seo.selected_kw where client="極簡乳清"')
  36. for c in cursor:
  37. lst.append([c['term'], c['domain']])
  38. obj = random.choice(lst)
  39. kw = obj[0]
  40. domain = obj[1]
  41. print(kw, domain)
  42. # os.chdir('/Users/zooeytsai/kw_tools/INNNews')
  43. intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}"')
  44. print('執行完成genetal_clickbot')
  45. if intval == -1:
  46. print('-1')
  47. sys.exit()
  48. db.close()
  49. while True:
  50. # run_once()
  51. run_specific()
  52. time.sleep(random.randint(120,150))