|
@@ -25,26 +25,6 @@ import redis
|
|
driver = None
|
|
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
|
|
|
|
- googleurl='https://www.google.com/search?q='+urllib.parse.quote(q)
|
|
|
|
- driver.get(googleurl)
|
|
|
|
- time.sleep(3)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def process_query(qs):
|
|
def process_query(qs):
|
|
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']
|
|
@@ -102,9 +82,7 @@ def process_query(qs):
|
|
|
|
|
|
def run_once(q):
|
|
def run_once(q):
|
|
global driver
|
|
global driver
|
|
- result=[]
|
|
|
|
s = Service('/root/driver/chromedriver')
|
|
s = Service('/root/driver/chromedriver')
|
|
- user_agent = rua()
|
|
|
|
options = webdriver.ChromeOptions()
|
|
options = webdriver.ChromeOptions()
|
|
options.add_argument('--headless')
|
|
options.add_argument('--headless')
|
|
options.add_argument('--remote-debugging-port=9222')
|
|
options.add_argument('--remote-debugging-port=9222')
|
|
@@ -122,7 +100,7 @@ def run_once(q):
|
|
change_ip = random.choice(change_ip_list)
|
|
change_ip = random.choice(change_ip_list)
|
|
options.add_argument(i5)
|
|
options.add_argument(i5)
|
|
#print('使用代理ip',change_ip)
|
|
#print('使用代理ip',change_ip)
|
|
-
|
|
|
|
|
|
+
|
|
driver = webdriver.Chrome(options=options,service=s)
|
|
driver = webdriver.Chrome(options=options,service=s)
|
|
|
|
|
|
driver.delete_all_cookies()
|
|
driver.delete_all_cookies()
|