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 def run_once(pport, dockername): db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4') lst = [] cursor = db.query('select * from seo.sns_kw') for c in cursor: lst.append([c['term'], c['url'], c['client'], c['domain']]) obj = random.choice(lst) kw = obj[0] url = obj[1] client = obj[2] domain = obj[3] print(kw, url) intval = os.system(f'python3 sns_clickbot.py get --kw="{kw}" --url="{url}" --client="{client}" --port="{str(pport)}" --domain="{domain}"') print('執行完成genetal_clickbot') if intval == -1: print('-1') sys.exit() db.close() class JParams(object): def get(self, port=9222): while True: try: os.system('docker container restart tiny7') time.sleep(1) run_once(9928, 'tiny7') time.sleep(20) break except: os.system('docker container restart tiny7') time.sleep(15) if __name__ == '__main__': fire.Fire(JParams)