|
@@ -18,18 +18,27 @@ import time
|
|
|
import traceback
|
|
|
import sys
|
|
|
import fire
|
|
|
-import pymysql
|
|
|
-pymysql.install_as_MySQLdb()
|
|
|
-import setting
|
|
|
+import random
|
|
|
|
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
|
|
|
table=db['general_log']
|
|
|
|
|
|
|
|
|
-
|
|
|
driver = None
|
|
|
|
|
|
|
|
|
+def rua():
|
|
|
+ pool = [
|
|
|
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0",
|
|
|
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0",
|
|
|
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
|
|
|
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36",
|
|
|
+ "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
|
|
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36",
|
|
|
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 OPR/68.0.3618.125",
|
|
|
+ ]
|
|
|
+ return random.choice(pool)
|
|
|
+
|
|
|
|
|
|
def empty_query(q):
|
|
|
global driver
|
|
@@ -78,7 +87,7 @@ def run_once(q):
|
|
|
result=[]
|
|
|
# s = Service('/root/driver/chromedriver')
|
|
|
s = Service('/Users/zooeytsai/Downloads/chromedriver 2')
|
|
|
- user_agent = setting.rua()
|
|
|
+ user_agent = rua()
|
|
|
options = webdriver.ChromeOptions()
|
|
|
options.add_argument('--headless')
|
|
|
options.add_argument('--remote-debugging-port=9222')
|