import sys import codecs import traceback import requests import re import pandas as pd import random import urllib import json import gspread import datetime from gspread_pandas import Spread, Client from oauth2client.service_account import ServiceAccountCredentials import os import redis import time 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('/Users/zooeytsai/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 = [] # cursor = db.query('select term, domain from ig_tags.select_kw where client="班尼斯口碑"') # for c in cursor: # lst.append([c['term'], c['domain']]) # obj = random.choice(lst) # kw = obj[0] kw_list = ['倉儲 管理'] kw = random.choice(kw_list) # domain = obj[1] domain = 'gs-rack.com' print(kw, domain) os.chdir('/Users/zooeytsai/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() while True: # run_once() run_specific() time.sleep(random.randint(120,150))