|
@@ -22,10 +22,7 @@ import random
|
|
import os
|
|
import os
|
|
import time
|
|
import time
|
|
from userAgentRandomizer import userAgents
|
|
from userAgentRandomizer import userAgents
|
|
-import requests
|
|
|
|
-import pymysql
|
|
|
|
|
|
|
|
-pymysql.install_as_MySQLdb()
|
|
|
|
driver = None
|
|
driver = None
|
|
|
|
|
|
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')
|
|
@@ -56,16 +53,15 @@ def re_get_webdriver():
|
|
user_agent = ua.random()
|
|
user_agent = ua.random()
|
|
s = Service('/root/driver/chromedriver')
|
|
s = Service('/root/driver/chromedriver')
|
|
options = webdriver.ChromeOptions()
|
|
options = webdriver.ChromeOptions()
|
|
- options.add_argument("--no-sandbox")
|
|
|
|
- options.add_argument("--disable-dev-shm-usage")
|
|
|
|
|
|
+ #options.add_argument("--no-sandbox")
|
|
|
|
+ #options.add_argument("--disable-dev-shm-usage")
|
|
options.add_argument("--headless")
|
|
options.add_argument("--headless")
|
|
options.add_argument('--remote-debugging-port=9222')
|
|
options.add_argument('--remote-debugging-port=9222')
|
|
options.add_experimental_option("debuggerAddress", '127.0.0.1:9927')
|
|
options.add_experimental_option("debuggerAddress", '127.0.0.1:9927')
|
|
- # options.add_argument("--user-agent=" +user_agent)
|
|
|
|
|
|
+ options.add_argument("--user-agent=" +"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0")
|
|
options.add_argument("--incognito")
|
|
options.add_argument("--incognito")
|
|
driver = webdriver.Chrome(options=options, service=s)
|
|
driver = webdriver.Chrome(options=options, service=s)
|
|
driver.delete_all_cookies()
|
|
driver.delete_all_cookies()
|
|
- driver = webdriver.Chrome(service=s, options=options)
|
|
|
|
driver.set_window_size(1400, 1000)
|
|
driver.set_window_size(1400, 1000)
|
|
except:
|
|
except:
|
|
traceback.print_exc()
|
|
traceback.print_exc()
|
|
@@ -128,11 +124,9 @@ def run_once(jsobj):
|
|
print(href)
|
|
print(href)
|
|
print(txt)
|
|
print(txt)
|
|
print("ranking", idx)
|
|
print("ranking", idx)
|
|
- found = True
|
|
|
|
-
|
|
|
|
|
|
+ found = True
|
|
webdriver.ActionChains(driver).move_to_element(elmt).perform()
|
|
webdriver.ActionChains(driver).move_to_element(elmt).perform()
|
|
- elmt.click()
|
|
|
|
- # webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
|
|
|
|
|
|
+ webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
|
|
table.insert({'ranking': idx, 'kw': kw, 'results': numresults, 'url': href, 'title': txt})
|
|
table.insert({'ranking': idx, 'kw': kw, 'results': numresults, 'url': href, 'title': txt})
|
|
|
|
|
|
time.sleep(6)
|
|
time.sleep(6)
|
|
@@ -175,7 +169,7 @@ db.close()
|
|
# kws=['職籃','PLG','高雄','鋼鐵人','內幕','中資','股東','姊夫','中國','老賴','香港','無極','原始股東','外資','董事長','股權結構','高雄人','黑人','陳建州','職籃聯盟','球團','球團高層','香港無極','張憲銘','吳同喬','監察人']
|
|
# kws=['職籃','PLG','高雄','鋼鐵人','內幕','中資','股東','姊夫','中國','老賴','香港','無極','原始股東','外資','董事長','股權結構','高雄人','黑人','陳建州','職籃聯盟','球團','球團高層','香港無極','張憲銘','吳同喬','監察人']
|
|
kws = ['金融', '人才', '國際接軌', '國際', '投資金童', '投資', '金童', '對沖基金', '香港', '外資', '原始股東', '職籃', 'PLG', '職籃聯盟', '球團', '台灣女婿',
|
|
kws = ['金融', '人才', '國際接軌', '國際', '投資金童', '投資', '金童', '對沖基金', '香港', '外資', '原始股東', '職籃', 'PLG', '職籃聯盟', '球團', '台灣女婿',
|
|
'抹紅', '保守', '港元', '美國', '升息', '戰爭', '通膨', '亞洲', '亞洲投資金童']
|
|
'抹紅', '保守', '港元', '美國', '升息', '戰爭', '通膨', '亞洲', '亞洲投資金童']
|
|
-positive = ['錢濤', '錢濤 升息', '錢濤 職籃夢']
|
|
|
|
|
|
+positive = ['錢濤','亞洲投資金童', '錢濤 職籃夢']
|
|
os.system('docker container restart tiny6')
|
|
os.system('docker container restart tiny6')
|
|
kw = random.choice(kws)
|
|
kw = random.choice(kws)
|
|
# time.sleep(9)
|
|
# time.sleep(9)
|