|
@@ -0,0 +1,66 @@
|
|
|
+#import redis
|
|
|
+import time
|
|
|
+import traceback
|
|
|
+#import json
|
|
|
+from selenium import webdriver
|
|
|
+from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
|
+import time
|
|
|
+import os
|
|
|
+from selenium.webdriver.support.ui import WebDriverWait
|
|
|
+from selenium.webdriver.common.by import By
|
|
|
+from selenium.webdriver.support import expected_conditions as EC
|
|
|
+from selenium.webdriver.common.action_chains import ActionChains
|
|
|
+import dataset
|
|
|
+import rpyc
|
|
|
+import random
|
|
|
+from selenium.webdriver.common.keys import Keys
|
|
|
+from userAgentRandomizer import userAgents
|
|
|
+
|
|
|
+lst=[]
|
|
|
+db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
|
|
|
+#os.system("docker container restart headless-shell")
|
|
|
+#time.sleep(6)
|
|
|
+cursor=db.query('SELECT * FROM columnids order by rand()')
|
|
|
+for c in cursor:
|
|
|
+ lst.append('https://www.hhh.com.tw/columns/detail/'+str(c['cid'])+'/')
|
|
|
+
|
|
|
+servers=[{'port':'10922','name':'tiny1'},{'port':'10924','name':'tiny2'},{'port':'10926','name':'tiny3'}]
|
|
|
+
|
|
|
+server=random.choice(servers)
|
|
|
+print(server)
|
|
|
+
|
|
|
+try:
|
|
|
+ conn = rpyc.classic.connect('192.168.192.9', port = 18812)
|
|
|
+except:
|
|
|
+ print('exception')
|
|
|
+ros=conn.modules.os
|
|
|
+ros.system('docker container restart '+server['name'])
|
|
|
+time.sleep(7)
|
|
|
+
|
|
|
+chrome_options = webdriver.ChromeOptions()
|
|
|
+chrome_options.add_argument("--incognito")
|
|
|
+chrome_options.add_argument("--headless")
|
|
|
+chrome_options.add_argument("--no-sandbox")
|
|
|
+chrome_options.add_argument("--disable-dev-shm-usage")
|
|
|
+
|
|
|
+
|
|
|
+ua = userAgents()
|
|
|
+user_agent = ua.random()
|
|
|
+
|
|
|
+
|
|
|
+chrome_options.add_argument("start-maximized")
|
|
|
+chrome_options.add_argument("user-data-dir=/tmp")
|
|
|
+chrome_options.add_argument("--user-agent=" +user_agent)
|
|
|
+
|
|
|
+chrome_options.debugger_address="192.168.192.9:"+server['port']
|
|
|
+chrome98=r'C:\portable\webdriver\chrome98\chromedriver.exe'
|
|
|
+driver = webdriver.Chrome(chrome_options=chrome_options,executable_path=chrome98)
|
|
|
+#while True:
|
|
|
+for i in range(12):
|
|
|
+ url=random.choice(lst)
|
|
|
+ print(url)
|
|
|
+ driver.get(url)
|
|
|
+ driver.execute_script('window.open("'+url+'","_blank");')
|
|
|
+ driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
|
|
|
+# time.sleep(0.2)
|
|
|
+
|