|
@@ -0,0 +1,88 @@
|
|
|
+# import redis
|
|
|
+import time
|
|
|
+import traceback
|
|
|
+# import json
|
|
|
+from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
|
+import time
|
|
|
+import os
|
|
|
+from selenium.webdriver.support.ui import WebDriverWait
|
|
|
+from selenium.webdriver.support import expected_conditions as EC
|
|
|
+import dataset
|
|
|
+from selenium import webdriver
|
|
|
+from selenium.webdriver.common.by import By
|
|
|
+from selenium.webdriver.common.keys import Keys
|
|
|
+from selenium.webdriver.chrome.service import Service
|
|
|
+import json
|
|
|
+import random
|
|
|
+import time
|
|
|
+import redis
|
|
|
+import sys
|
|
|
+import codecs
|
|
|
+import random
|
|
|
+import os
|
|
|
+import time
|
|
|
+from userAgentRandomizer import userAgents
|
|
|
+import requests
|
|
|
+
|
|
|
+driver = None
|
|
|
+
|
|
|
+
|
|
|
+headers = {
|
|
|
+ "Authorization": "Bearer " + "6SDULL1Ebklduc6TFxa97AFto5Sj21kyJ30CxiLiSoi",
|
|
|
+ "Content-Type": "application/x-www-form-urlencoded"
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+def send_msg(kw):
|
|
|
+ params = {"message": kw}
|
|
|
+ r = requests.post("https://notify-api.line.me/api/notify", headers=headers, params=params)
|
|
|
+
|
|
|
+
|
|
|
+def re_get_webdriver():
|
|
|
+ global port
|
|
|
+ global driver
|
|
|
+ result = []
|
|
|
+ if driver is not None:
|
|
|
+ print('closing....')
|
|
|
+ driver.quit()
|
|
|
+ os.system('killall chrome')
|
|
|
+ print('quit....')
|
|
|
+ driver = None
|
|
|
+ try:
|
|
|
+ s = Service('/root/driver/chromedriver')
|
|
|
+ options = webdriver.ChromeOptions()
|
|
|
+ options.add_argument("--no-sandbox")
|
|
|
+ options.add_argument("--disable-dev-shm-usage")
|
|
|
+ options.add_argument("--headless")
|
|
|
+ options.add_argument('--remote-debugging-port=9222')
|
|
|
+ options.add_experimental_option("debuggerAddress", '127.0.0.1:9927')
|
|
|
+ options.add_argument("--incognito")
|
|
|
+ r = redis.Redis(host='db.ptt.cx', port=6379, db=2, password='choozmo9')
|
|
|
+ data = r.get('google_proxy')
|
|
|
+ jstext = data.decode('utf-8')
|
|
|
+ jsobj = json.loads(jstext)
|
|
|
+ proxy = random.choice(jsobj)
|
|
|
+ change_ip_list = ['--proxy-server=%s' % proxy, "--proxy-server=socks5://127.0.0.1:9050",
|
|
|
+ "--proxy-server=socks5://192.53.174.202:8180"]
|
|
|
+ change_ip = random.choice(change_ip_list)
|
|
|
+ options.add_argument(change_ip)
|
|
|
+ print('使用代理ip', change_ip)
|
|
|
+ driver.delete_all_cookies()
|
|
|
+ driver = webdriver.Chrome(service=s, options=options)
|
|
|
+ driver.set_window_size(1400, 1000)
|
|
|
+ except:
|
|
|
+ traceback.print_exc()
|
|
|
+ driver = None
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
+def run_once(jsobj):
|
|
|
+ global driver
|
|
|
+ driver.get('https://api.ipify.org/')
|
|
|
+ time.sleep(3)
|
|
|
+ ip_address = driver.find_element(By.TAG_NAME, "body").text
|
|
|
+ print(ip_address)
|
|
|
+ driver.quit()
|
|
|
+
|
|
|
+
|
|
|
+
|