import sys import codecs import traceback import re import pandas as pd import random import os import redis import time import json import fire import dataset import pymysql pymysql.install_as_MySQLdb() def run_once(): db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4') lst = ['倉儲管理 神助移動貨架','倉儲管理 神助貨架','倉儲 管理'] # cursor = db.query('select term, domain from seo.selected_kw where client="仁本"') # for c in cursor: # lst.append([c['term'], c['domain']]) obj = random.choice(lst) kw = obj domain = 'jiatetea.tw' print(kw, domain) os.chdir('C:\/Users\/s1301\/PycharmProjects\/kw_tools\/INNNews') intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}"') print('執行完成genetal_clickbot') if intval == -1: print('-1') sys.exit() db.close() def run_specific(): db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4') # db_local = dataset.connect('mysql://root:jondae350@localhost/ig_tags') lst = [] ####形象SEO#### # cursor = db.query('select json from seo.seo_jobs where id between 770 and 770 order by rand() limit 1') # for c in cursor: # js = json.loads(c['json']) # prefix = js['prefix'] # postfix = js['postfix'] # domain = js['domain'][0] # positive = js['positive'] # rnd = js['rnd'] # # kw1 = random.choice(positive) # kw2 = random.choice(rnd) # kw = prefix + " " + kw1 + " " + kw2 # print(kw,domain) ###形象SEO### cursor = db.query('select term, domain from seo.selected_kw where client="美麗馨"') for c in cursor: lst.append([c['term'], c['domain']]) obj = random.choice(lst) kw = obj[0] domain = obj[1] print(kw, domain) intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}"') print('執行完成genetal_clickbot') if intval == -1: print('-1') sys.exit() db.close() while True: # run_once() run_specific() time.sleep(random.randint(120,150))