1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import sys
- import random
- import os
- import time
- import fire
- import dataset
- from random import randint
- import pymysql
- pymysql.install_as_MySQLdb()
- def run_once(pport, dockername):
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
- lst = []
-
- cursor = db.query('select term,domain from seo.selected_kw')
- for c in cursor:
- lst.append([c['term'], c['domain']])
- cur = db.query('select * from seo.google_rank order by id desc limit 1')
- count_row = db.query('select count(*) from seo.google_rank where CAST(dt AS DATE) = CAST( curdate() AS DATE)')
- for c in cur:
- kw = c['keyword']
- for c in count_row:
- now_day_len = c['count(*)']
- print(now_day_len)
- if now_day_len == 0:
- print('首位')
- intval = os.system(
- f'python3 ranking_day.py get --kw="清原 中央" --domain="taroboba-yuan.com" --port="{str(pport)}"')
-
- for i in lst:
- if i[0] == kw:
- id = lst.index(i)
- intval = os.system(f'python3 ranking_day.py get --kw="{lst[id+1][0]}" --domain="{lst[id+1][1]}" --port="{str(pport)}"')
- print('執行ranking_day.py')
- if intval == -1:
- print('-1')
- sys.exit()
- class JParams(object):
-
- def get(self, port=9222):
- while True:
- try:
- os.system('docker container restart tiny9')
- time.sleep(1)
- run_once(9928,'tiny9')
- time.sleep(20)
- break
- except:
- os.system('docker container restart tiny9')
- time.sleep(15)
- # if __name__ == '__main__':
- # run_once()
|