Python

Selenium Wire Option

Kyle79 2022. 12. 11. 14:22
d = DesiredCapabilities.CHROME
d['loggingPrefs'] = {'browser': 'ALL'}
d['acceptSslCerts'] = True

# Chrome mini
chromium = '/home/usr/chrome/headless-chromium'
if os.path.exists(chromium):
    chrome_options.binary_location = chromium
    
if not os.path.exists(chrome_path):
    chrome_path = '/usr/local/bin/chromedriver'
    
if wired:
    sw_options = { 
        # 'request_storage': 'memory',
        # 'request_storage_max_size': 100,
        # 'ignore_http_methods': [],
    }
    
    if len(proxy_list) > 0:
        proxy = random.choice(proxy_list)
        ip = proxy['ip']
        port = proxy['port']
        sw_options['proxy'] = {
            'http': f'http://{ip}:{port}', 
            'https': f'http://{ip}:{port}', 
            'no_proxy': 'localhost,127.0.0.1'
        }
        
    chrome = wired_webdriver.Chrome(chrome_path, options=chrome_options, desired_capabilities=d, seleniumwire_options=sw_options)    
else:
    chrome = webdriver.Chrome(chrome_path, options=chrome_options, desired_capabilities=d)    

chrome.implicitly_wait(timeout)

'Python' 카테고리의 다른 글

Selenium Wire  (0) 2022.12.11
User-agent generator  (0) 2022.12.11
Selenium Chrome Option  (0) 2022.12.11
ChromeDriver & Selenium Wire setting  (0) 2022.12.11
pip 설치시, SSL 오류  (0) 2022.04.02