zooey %!s(int64=2) %!d(string=hai) anos
pai
achega
67fd4ffda7
Modificáronse 2 ficheiros con 39 adicións e 22 borrados
  1. 39 21
      SEO/notify_nda.py
  2. 0 1
      SEO/seo_notify_gs.py

+ 39 - 21
SEO/notify_nda.py

@@ -5,49 +5,67 @@ 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
-from bs4 import BeautifulSoup
 import requests
 import dataset
 import time
-import rpyc
 import sys
 import docker
+import dataset
 import pymysql
 pymysql.install_as_MySQLdb()
-from monitor import GA_innnews
+
 
 headers = {
-        "Authorization": "Bearer " + "zsaS4I79fkbun9LLF8mQmeHL4PlEtBtN7OLzTp8m72Y",
-        "Content-Type": "application/x-www-form-urlencoded"
+    "Authorization": "Bearer " + "OZDcq7sVKwr3F6YNLtBF3LuIgpa4Ql9eAnBWeD7sHTJ",
+    "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)
+    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.nda_log where domain = "innews.com.tw" and datediff(now(),dt)=0 order by dt desc')
-result="\n"
-idx=0
+cursor = db.query('SELECT * FROM seo.nda_log where datediff(now(),dt)=0 order by dt desc')
+
+result = "\n"
+idx = 0
+d = {'波囍': 0, '龔國權': 0, '信義': 0, '護': 0, 'angelo koo': 0}
+d_computer = {'64G':0,'p1':0,'p2':0,'i5':0,'7000':0,'139':0}
 for c in cursor:
-    idx+=1
-    if idx<=3:
-        elmt=c['kw']
-        result+="["+str(c['ranking'])+"]:"+elmt+"\n"
+    custom_name = c['kw']
+    client = c['client']
+    for i in d:
+        check = re.match(i,custom_name)
+        if check:
+            d[i] += 1
+    for j in d_computer:
+        check_2 = re.match(str(j),str(client))
+        if check_2:
+            d_computer[j]+=1
+
+per_total_click = f"波囍:{d['波囍']}\nKNIGHT:{d['龔國權']}\n信義房屋:{d['信義']}\n護佳:{d['護']}\n美東:{d['angelo koo']}\n"
+computer_total_click = f"64G:{d_computer['64G']}\np1:{d_computer['p1']}\np2:{d_computer['p2']}\ni5:{d_computer['i5']}\n7000:{d_computer['7000']}\n139:{d_computer['139']}\n"
+print(per_total_click)
+print(computer_total_click)
+msg_per_total_click = '\n點擊次數總計:\n' + 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 + result + computer_total_click)
+db.close()
 
-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"
 
-# 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))

+ 0 - 1
SEO/seo_notify_gs.py

@@ -27,7 +27,6 @@ headers = {
     "Content-Type": "application/x-www-form-urlencoded"
 }
 
-name = {'taroboba-yuan.com':'清原','hhh.com.tw':['幸福空間','幸福空間設計師'],'sctt.com.tw':'仁本','gs-rack.com':'神助物流','gs-rack.com/tag':'神助物流','bennis.com.tw':'班尼斯','yogoclean.com':'有夠讚','yesonlineeng.com':'新飛'}
 
 def send_msg(kw):
     params = {"message": kw}