123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import time
- import json
- from selenium import webdriver
- from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
- import time
- import os
- import re
- 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
- import requests
- import dataset
- import time
- import sys
- import docker
- import dataset
- import pymysql
- pymysql.install_as_MySQLdb()
- headers = {
- "Authorization": "Bearer " + "OZDcq7sVKwr3F6YNLtBF3LuIgpa4Ql9eAnBWeD7sHTJ",
- "Content-Type": "application/x-www-form-urlencoded"
- }
- def send_msg(kw):
- params = {"message": kw}
- print('通知結果', params)
- r = requests.post("https://notify-api.line.me/api/notify", headers=headers, params=params)
- # db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
- db = dataset.connect('postgresql://postgres:eyJhbGciOiJI@172.105.241.163:5432/postgres')
- # cursor = db.query('SELECT * FROM seo.nda_log where datediff(now(),dt)=0 order by dt desc')
- cursor = db.query('SELECT * FROM public.seo_jobs_ranking where CAST(avg_neg AS numeric) = 0 and now()::date = dt::date')
- result = "\n"
- idx = 0
- lst = []
- result = ""
- for c in cursor:
- lst.append(c['kw'])
- result+=f"{c['kw']}\n"
- msg_per_total_click = '\n分數等於0分的關鍵字:\n' + result
- print(msg_per_total_click)
- msg = "\n機器人執行次數:" + str(idx)
- # print(msg_per_total_click + result + sns_per_total_click + sns_result + ga_sessions)
- send_msg(msg_per_total_click)
- db.close()
- # schtasks /create /sc minute /mo 30 /sd 2022/05/050 /st 9:00 /et 23:00 /tn "linebat" /tr "C:\tmp\inn_line.bat"
- SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
- sys.path.append(os.path.dirname(SCRIPT_DIR))
|