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() <<<<<<< HEAD from ga_click import main ======= from monitor.ga_click import main >>>>>>> 604b4f0737fe7f055de28e84a0a4697a346701cf headers = { "Authorization": "Bearer " + "OZDcq7sVKwr3F6YNLtBF3LuIgpa4Ql9eAnBWeD7sHTJ", "Content-Type": "application/x-www-form-urlencoded" } name = {'beastparadise.net':'毛怪','taroboba-yuan.com':'清原','match-planet.com':'火柴星人','hhh.com.tw':['幸福空間','幸福空間設計師'],'sctt.com.tw':'仁本'} 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') cursor = db.query( 'SELECT * FROM seo.general_log where domain != "innews.com.tw" and datediff(now(),dt)=0 order by dt desc') cursor_rank = db.query( 'SELECT * FROM seo.google_rank where datediff(now(),dt)=0 order by dt desc') result = "\n" idx = 0 d = {'beastparadise.net':0,'match-planet.com':0,'taroboba-yuan.com':0,'hhh.com.tw':0,'sctt.com.tw':0,'hhh.com.tw/designer':0} for c in cursor: custom_name = c['domain'] if custom_name in d: if custom_name == 'hhh.com.tw' and c['num']==1: d['hhh.com.tw/designer']+=1 d[custom_name]+=1 idx += 1 if idx <= 3: elmt = c['kw'] domain = c['domain'] custom_name = name[domain] result += "[" + str(c['ranking']) + "]:" + elmt + " "+ f"({custom_name})\n" per_total_click = f"毛怪:{d['beastparadise.net']}\n清原:{d['taroboba-yuan.com']}\n火柴星人:{d['match-planet.com']}\n幸福空間:{d['hhh.com.tw']}\n幸福空間設計師:{d['hhh.com.tw/designer']}\n仁本:{d['sctt.com.tw']}\n" print(per_total_click) msg_per_total_click = '\n點擊次數總計:\n' + per_total_click msg = "\n機器人執行次數:" + str(idx) <<<<<<< HEAD ga = main()['ga:sessions'] ga_sessions = '\n幸福空間的GA Sessions'+ ga ======= ga_sessions = '\n幸福空間的GA Sessions'+main()['ga:sessions'] >>>>>>> 604b4f0737fe7f055de28e84a0a4697a346701cf send_msg(msg_per_total_click + result + ga_sessions) # 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))