|
@@ -7,34 +7,28 @@ import os
|
|
import urllib.parse
|
|
import urllib.parse
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.common.by import By
|
|
|
|
+from selenium.webdriver.chrome.service import Service
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
import codecs
|
|
import codecs
|
|
import random
|
|
import random
|
|
import requests
|
|
import requests
|
|
import datetime
|
|
import datetime
|
|
import dataset
|
|
import dataset
|
|
|
|
+import pymysql
|
|
|
|
+pymysql.install_as_MySQLdb()
|
|
import time
|
|
import time
|
|
import traceback
|
|
import traceback
|
|
import sys
|
|
import sys
|
|
import fire
|
|
import fire
|
|
-#from INNNews import notifytest
|
|
|
|
|
|
+
|
|
|
|
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
|
|
table=db['general_log']
|
|
table=db['general_log']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-driver=None
|
|
|
|
-headers = {
|
|
|
|
- "Authorization": "Bearer " + "t35vhZtWNgvDNWHc3DJh0OKll3mcB9GvC8K2EAkBug2",
|
|
|
|
- "Content-Type": "application/x-www-form-urlencoded"
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+driver = None
|
|
|
|
|
|
-def send_msg(kw):
|
|
|
|
- params = {"message": "處理關鍵字: "+kw}
|
|
|
|
- r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params=params)
|
|
|
|
|
|
|
|
|
|
|
|
def empty_query(q):
|
|
def empty_query(q):
|
|
@@ -79,18 +73,16 @@ def process_query(qs):
|
|
def run_once(q):
|
|
def run_once(q):
|
|
global driver
|
|
global driver
|
|
result=[]
|
|
result=[]
|
|
|
|
+ s = Service('/root/driver')
|
|
options = webdriver.ChromeOptions()
|
|
options = webdriver.ChromeOptions()
|
|
options.add_argument('--headless')
|
|
options.add_argument('--headless')
|
|
-
|
|
|
|
- options.add_argument('--disable-dev-shm-usage')
|
|
|
|
- options.add_argument('--no-sandbox')
|
|
|
|
- options.add_argument('--remote-debugging-port=9222')
|
|
|
|
-
|
|
|
|
|
|
+ # options.add_argument('--remote-debugging-port=9222')
|
|
|
|
+ options.add_experimental_option("debuggerAddress", "192.168.192.45:9922")
|
|
# options.add_argument("--user-agent=" +user_agent)
|
|
# options.add_argument("--user-agent=" +user_agent)
|
|
options.add_argument("--incognito")
|
|
options.add_argument("--incognito")
|
|
|
|
|
|
driver = webdriver.Chrome(
|
|
driver = webdriver.Chrome(
|
|
- options=options)
|
|
|
|
|
|
+ options=options,service=s)
|
|
|
|
|
|
driver.delete_all_cookies()
|
|
driver.delete_all_cookies()
|
|
driver.set_window_size(1400,1000)
|
|
driver.set_window_size(1400,1000)
|