|
@@ -5,7 +5,8 @@ import time
|
|
import fire
|
|
import fire
|
|
import dataset
|
|
import dataset
|
|
from random import randint
|
|
from random import randint
|
|
-
|
|
|
|
|
|
+import pymysql
|
|
|
|
+pymysql.install_as_MySQLdb()
|
|
|
|
|
|
def run_once(pport, dockername):
|
|
def run_once(pport, dockername):
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
|
|
@@ -16,16 +17,23 @@ def run_once(pport, dockername):
|
|
lst.append([c['term'], c['domain']])
|
|
lst.append([c['term'], c['domain']])
|
|
|
|
|
|
cur = db.query('select * from seo.google_rank order by id desc limit 1')
|
|
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:
|
|
for c in cur:
|
|
kw = c['keyword']
|
|
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:
|
|
for i in lst:
|
|
if i[0] == kw:
|
|
if i[0] == kw:
|
|
- id = lst.index(i[0])
|
|
|
|
- intval = os.system(f'python3 ranking_day.py get --kw="{lst[id+1]}" --domain="{i[id+1]}" --port="{str(pport)}"')
|
|
|
|
-
|
|
|
|
|
|
+ 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')
|
|
print('執行ranking_day.py')
|
|
- time.sleep(randint(180,190))
|
|
|
|
if intval == -1:
|
|
if intval == -1:
|
|
print('-1')
|
|
print('-1')
|
|
sys.exit()
|
|
sys.exit()
|
|
@@ -39,14 +47,13 @@ class JParams(object):
|
|
os.system('docker container restart tiny9')
|
|
os.system('docker container restart tiny9')
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
run_once(9928,'tiny9')
|
|
run_once(9928,'tiny9')
|
|
-
|
|
|
|
time.sleep(20)
|
|
time.sleep(20)
|
|
-
|
|
|
|
|
|
+ break
|
|
except:
|
|
except:
|
|
- os.system('docker container restart tiny4')
|
|
|
|
|
|
+ os.system('docker container restart tiny9')
|
|
time.sleep(15)
|
|
time.sleep(15)
|
|
|
|
|
|
|
|
|
|
-if __name__ == '__main__':
|
|
|
|
- fire.Fire(JParams)
|
|
|
|
|
|
+# if __name__ == '__main__':
|
|
|
|
+# run_once()
|
|
|
|
|