import redis import time import json from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities import time import os import urllib.parse from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC import codecs import random from bs4 import BeautifulSoup import requests import dataset import time import rpyc import sys import docker import pymysql pymysql.install_as_MySQLdb() headers = { "Authorization": "Bearer " + "zsaS4I79fkbun9LLF8mQmeHL4PlEtBtN7OLzTp8m72Y", "Content-Type": "application/x-www-form-urlencoded" } def send_msg(kw): params = {"message": kw} 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 10 /st 09:00 /et 23:00 /tn "linebat" /tr "C:\tmp\inn_line.bat"