|
@@ -52,8 +52,6 @@ def re_get_webdriver():
|
|
print('quit....')
|
|
print('quit....')
|
|
driver = None
|
|
driver = None
|
|
try:
|
|
try:
|
|
- ua = userAgents()
|
|
|
|
- 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("--no-sandbox")
|
|
@@ -61,9 +59,17 @@ def re_get_webdriver():
|
|
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("--incognito")
|
|
options.add_argument("--incognito")
|
|
- driver = webdriver.Chrome(options=options, service=s)
|
|
|
|
|
|
+ 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.delete_all_cookies()
|
|
driver = webdriver.Chrome(service=s, options=options)
|
|
driver = webdriver.Chrome(service=s, options=options)
|
|
driver.set_window_size(1400, 1000)
|
|
driver.set_window_size(1400, 1000)
|