| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | import redisimport timeimport jsonfrom selenium import webdriverfrom selenium.webdriver.common.desired_capabilities import DesiredCapabilitiesimport timeimport osimport urllib.parsefrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support import expected_conditions as ECimport codecsimport randomfrom bs4 import BeautifulSoupimport requestsimport datasetimport timeimport rpycimport sysimport dockerimport pymysqlpymysql.install_as_MySQLdb()from monitor import GA_innnewsheaders = {        "Authorization": "Bearer " + "zsaS4I79fkbun9LLF8mQmeHL4PlEtBtN7OLzTp8m72Y",        "Content-Type": "application/x-www-form-urlencoded"}def send_msg(kw):    send_message = GA_innnews.main()    params = {"message": kw+send_message['message']}    print('通知結果',params)    r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params=params)while True:    db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')    cursor=db.query('SELECT * FROM seo.general_log where domain = "innews.com.tw" and datediff(now(),dt)=0 order by dt desc')    result="\n"    idx=0    for c in cursor:        idx+=1        if idx<=3:            elmt=c['kw']            result+="["+str(c['ranking'])+"]:"+elmt+"\n"        msg="\n機器人執行次數:"+str(idx)    send_msg(msg+result)    time.sleep(1800)# schtasks /create /sc minute /mo 30 /sd 2022/05/050 /st 9:00 /et 23:00 /tn "linebat" /tr "C:\tmp\inn_line.bat"
 |