|
@@ -15,24 +15,27 @@ import os
|
|
|
import redis
|
|
|
import time
|
|
|
import fire
|
|
|
+import dataset
|
|
|
|
|
|
|
|
|
def run_once(pport, dockername):
|
|
|
- r = redis.Redis(host='db.ptt.cx', port=6379, db=1, password='choozmo9')
|
|
|
- js = r.get('innews_sheet')
|
|
|
- jsobj = json.loads(js)
|
|
|
-
|
|
|
- kw = random.choice(jsobj) # 第一次(三組關鍵字)
|
|
|
+ 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']])
|
|
|
+
|
|
|
+ obj = random.choice(lst)
|
|
|
+ kw = obj[0]
|
|
|
+ domain = obj[1]
|
|
|
+ print(kw,domain)
|
|
|
+
|
|
|
+ intval = os.system(f'python general_clickbot.py get --kw={kw} --domain={domain} --port={str(pport)}')
|
|
|
|
|
|
- kw_innews = '引新聞 ' # 第二次(隨機選擇兩組關鍵字與引新聞)
|
|
|
- num = random.choices([0, 1, 2], k=2)
|
|
|
- for i in num:
|
|
|
- kw_innews += kw['kw'].split(' ')[i] + ' '
|
|
|
- print(kw)
|
|
|
- intval = os.system(
|
|
|
- 'python general_clickbot_local.py get --kw="' + kw['kw'] + '" --domain=innews.com.tw --port=' + str(pport))
|
|
|
- print('等待')
|
|
|
- print(intval)
|
|
|
+ print('執行genetal_clickbot')
|
|
|
+
|
|
|
if intval == -1:
|
|
|
print('-1')
|
|
|
sys.exit()
|