run_sheet_local.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 json
  11. import fire
  12. import dataset
  13. import pymysql
  14. pymysql.install_as_MySQLdb()
  15. def run_once():
  16. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  17. lst = ['倉儲管理 神助移動貨架','倉儲管理 神助貨架','倉儲 管理']
  18. # cursor = db.query('select term, domain from seo.selected_kw where client="仁本"')
  19. # for c in cursor:
  20. # lst.append([c['term'], c['domain']])
  21. obj = random.choice(lst)
  22. kw = obj
  23. domain = 'jiatetea.tw'
  24. print(kw, domain)
  25. os.chdir('C:\/Users\/s1301\/PycharmProjects\/kw_tools\/INNNews')
  26. intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}"')
  27. print('執行完成genetal_clickbot')
  28. if intval == -1:
  29. print('-1')
  30. sys.exit()
  31. db.close()
  32. def run_specific():
  33. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  34. # db_local = dataset.connect('mysql://root:jondae350@localhost/ig_tags')
  35. lst = []
  36. ####形象SEO####
  37. # cursor = db.query('select json from seo.seo_jobs where id between 770 and 770 order by rand() limit 1')
  38. # for c in cursor:
  39. # js = json.loads(c['json'])
  40. # prefix = js['prefix']
  41. # postfix = js['postfix']
  42. # domain = js['domain'][0]
  43. # positive = js['positive']
  44. # rnd = js['rnd']
  45. #
  46. # kw1 = random.choice(positive)
  47. # kw2 = random.choice(rnd)
  48. # kw = prefix + " " + kw1 + " " + kw2
  49. # print(kw,domain)
  50. ###形象SEO###
  51. cursor = db.query('select term, domain from seo.selected_kw where client="美麗馨"')
  52. for c in cursor:
  53. lst.append([c['term'], c['domain']])
  54. obj = random.choice(lst)
  55. kw = obj[0]
  56. domain = obj[1]
  57. print(kw, domain)
  58. intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}"')
  59. print('執行完成genetal_clickbot')
  60. if intval == -1:
  61. print('-1')
  62. sys.exit()
  63. db.close()
  64. while True:
  65. # run_once()
  66. run_specific()
  67. time.sleep(random.randint(120,150))