notifytest.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import redis
  2. import time
  3. import json
  4. from selenium import webdriver
  5. from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  6. import time
  7. import os
  8. import urllib.parse
  9. from selenium.webdriver.support.ui import WebDriverWait
  10. from selenium.webdriver.common.by import By
  11. from selenium.webdriver.support import expected_conditions as EC
  12. import codecs
  13. import random
  14. from bs4 import BeautifulSoup
  15. import requests
  16. import dataset
  17. import time
  18. import rpyc
  19. import sys
  20. import docker
  21. import pymysql
  22. pymysql.install_as_MySQLdb()
  23. from monitor import GA_innnews
  24. headers = {
  25. "Authorization": "Bearer " + "zsaS4I79fkbun9LLF8mQmeHL4PlEtBtN7OLzTp8m72Y",
  26. "Content-Type": "application/x-www-form-urlencoded"
  27. }
  28. def send_msg(kw):
  29. send_message = GA_innnews.main()
  30. params = {"message": kw+send_message['message']}
  31. print('通知結果',params)
  32. # r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params=params)
  33. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  34. cursor=db.query('SELECT * FROM seo.nda_log where domain = "innews.com.tw" and datediff(now(),dt)=0 order by dt desc')
  35. result="\n"
  36. idx=0
  37. for c in cursor:
  38. idx+=1
  39. if idx<=3:
  40. elmt=c['kw']
  41. result+="["+str(c['ranking'])+"]:"+elmt+"\n"
  42. msg="\n機器人執行次數:"+str(idx)
  43. send_msg(msg+result)
  44. time.sleep(1800)
  45. # schtasks /create /sc minute /mo 30 /sd 2022/05/050 /st 9:00 /et 23:00 /tn "linebat" /tr "C:\tmp\inn_line.bat"