|
@@ -0,0 +1,68 @@
|
|
|
+import sys
|
|
|
+import codecs
|
|
|
+import traceback
|
|
|
+import requests
|
|
|
+import re
|
|
|
+import pandas as pd
|
|
|
+import random
|
|
|
+import urllib
|
|
|
+import json
|
|
|
+import gspread
|
|
|
+import fire
|
|
|
+import datetime
|
|
|
+from gspread_pandas import Spread, Client
|
|
|
+from oauth2client.service_account import ServiceAccountCredentials
|
|
|
+import os
|
|
|
+import redis
|
|
|
+import time
|
|
|
+
|
|
|
+def run_once(pport):
|
|
|
+ os.system('docker container restart tiny1')
|
|
|
+ time.sleep(5)
|
|
|
+ r = redis.Redis(host='db.ptt.cx', port=6379, db=1,password='choozmo9')
|
|
|
+ js=r.get('innews_sheet')
|
|
|
+ jsobj=json.loads(js)
|
|
|
+
|
|
|
+ mywords=['引新聞 集仕多','集仕多 元宇宙','集仕多 策展','南橘','茶葉直播','連千毅nft','南投龍華宮','元欣']
|
|
|
+ while True:
|
|
|
+ kw=random.choice(jsobj) # 第一次(三組關鍵字)
|
|
|
+
|
|
|
+ kw_innews = '引新聞 ' # 第二次(隨機選擇兩組關鍵字與引新聞)
|
|
|
+ num = random.choices([0,1,2],k=2)
|
|
|
+ for i in num:
|
|
|
+ kw_innews+=kw['kw'].split(' ')[i]+' '
|
|
|
+
|
|
|
+ r=random.randint(0,1)
|
|
|
+ if r==0:
|
|
|
+ kw['kw']='集仕多 策展'
|
|
|
+ # print(kw)
|
|
|
+
|
|
|
+
|
|
|
+ # os.chdir('/Users/zooeytsai/kw_tools/INNNews')
|
|
|
+# os.chdir('c:/gitlab/kw_tools/kw_tools/INNNews')
|
|
|
+# os.chdir('c:/gitlab/kw_tools/kw_tools/INNNews')
|
|
|
+
|
|
|
+ print( 'python3 local_general_clickbot.py get --kw="'+kw['kw']+'" --domain=innews.com.tw --port='+str(pport))
|
|
|
+ os.system('python3 local_general_clickbot.py get --kw="'+kw['kw']+'" --domain=innews.com.tw --port='+str(pport))
|
|
|
+ print('等待')
|
|
|
+ time.sleep(5)
|
|
|
+
|
|
|
+ # time.sleep(120)
|
|
|
+ # time.sleep(120)
|
|
|
+ # os.system('python3 general_clickbot.py get --kw="'+kw_innews+'" --domain=innews.com.tw')
|
|
|
+
|
|
|
+ # os.system('python notifytest.py send_msg')
|
|
|
+
|
|
|
+
|
|
|
+class JParams(object):
|
|
|
+
|
|
|
+ def get(self, port=9222):
|
|
|
+ print(port)
|
|
|
+ try:
|
|
|
+ run_once( port )
|
|
|
+ except:
|
|
|
+ os.system('docker container restart tiny1')
|
|
|
+ time.sleep(6)
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ fire.Fire(JParams)
|