You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from Common import base_url
from seleniumwire import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from Proxypool import Threads_spider,Get_UA
from random import randint
class ClassDriver:
def __init__(self):
self.driver = None
self.baseurl = base_url()
self.IPS = Threads_spider()
def get_Options(self):
"""
启动器设置
:return: 启动器对象
"""
options = webdriver.ChromeOptions()
# 禁止图片和css加载禁用js
options.add_argument("--disable-javascript")
prefs = {"profile.managed_default_content_settings.images": 2, 'permissions.default.stylesheet': 2}
options.add_experimental_option("prefs", prefs)
# 伪造UA头
options.add_argument("--disable-cookies")
options.add_argument('--disable-dev-shm-usage')
options.add_argument(
'user-agent=' + Get_UA())
options.add_argument('--window-size=1400,900')
options.add_argument('ignore-certificate-errors')
options.add_argument(f"--proxy-server={self.IPS[randint(0, len(self.IPS))]}")
options.add_argument('--headless')
options.add_argument('--hide-scrollbars')
self.driver = webdriver.Chrome(options=options)
return self.driver
def get_WAIT(self):
return WebDriverWait(self.driver, 10)