run_sheet_2.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 cust, json from seo.seo_jobs where cust="啟翔" order by rand() limit 1')
  38. # cursor = db.query('select cust, json from seo.seo_jobs where cust=""')
  39. # cursor = db.query('select json from seo.seo_jobs where id between 2775 and 2793')
  40. ### 測試開始部分 ###
  41. # for c in cursor:
  42. # print(c['json'])
  43. # js = json.loads(c['json'])
  44. # prefix = js['prefix']
  45. # postfix = js['postfix']
  46. # domain = js['domain'][0]
  47. # positive = js['positive']
  48. # rnd = js['rnd']
  49. # kw1 = random.choice(positive)
  50. # kw2 = random.choice(rnd)
  51. # kw = prefix + " " + kw1 + " " + kw2
  52. # print(kw, domain)
  53. ### 測試結束部分 ###
  54. # for c in cursor:
  55. # js = json.loads(c['json'])
  56. # prefix = js['prefix']
  57. # postfix = js['postfix']
  58. # domain = js['domain'][0]
  59. # positive = js['positive']
  60. # rnd = js['rnd']
  61. # client = c['cust']
  62. # print(prefix)
  63. # kw1 = random.choice(positive)
  64. # kw2 = random.choice(rnd)
  65. # kw = prefix + " " + kw1 + " " + kw2
  66. ##########
  67. # cursor = db.query('select term, domain from seo.selected_kw where client="幸福空間"')
  68. # for c in cursor:
  69. # lst.append([c['term'], c['domain']])
  70. lst = ['裝修預算','裝潢預算']
  71. domain = 'hhh.com.tw/calculator_request'
  72. obj = random.choice(lst)
  73. kw = obj[0]
  74. client = '幸福空間'
  75. # domain = obj[1]
  76. print(kw, domain)
  77. intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}" --client="{client}"')
  78. print('執行完成genetal_clickbot')
  79. if intval == -1:
  80. print('-1')
  81. sys.exit()
  82. db.close()
  83. # run_specific()
  84. while True:
  85. # run_once()
  86. run_specific()
  87. time.sleep(random.randint(120, 150))
  88. #