I am trying to implement Bright Data proxy Residential IPs services into my Python Selenium code that is firing a webpage. Even when that page has a SSL certificate, it is loading in http not https.
I am getting certificate errors in my terminal.
My code:
# from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.proxy import *
from selenium.common.exceptions import NoSuchElementException
from fake_useragent import UserAgent
import os, sys
from selenium.webdriver.chrome.service import Service as ChromeService
from seleniumwire import webdriver
delay = 30
custom_wait_time = 5
ua = UserAgent()
host = 'HOST'
port = 'PORT'
username = 'USERNAME'
password = 'PASSWORD'
proxy_url = f'http://{username}:{password}@{host}:{port}'
# set selenium-wire options to use the proxy
seleniumwire_options = {
"proxy": {
"http": proxy_url,
"https": proxy_url
},
}
options = webdriver.ChromeOptions()
options.add_argument(f"user-agent={ua.random}")
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")
options.add_argument("--start-maximized")
options.add_argument('--proxy-server=%s' % proxy_url)
options.add_experimental_option("useAutomationExtension", False)
options.add_experimental_option("excludeSwitches", ["enable-automation"])
# initialize the Chrome driver with service, selenium-wire options, and chrome options
driver = webdriver.Chrome(
service=Service(ChromeDriverManager().install()),
seleniumwire_options=seleniumwire_options,
options=options
)
webdriver.DesiredCapabilities.CHROME['acceptSslCerts']=True
# navigate to the target webpage
driver.get("https://guideuncle.com/")
time.sleep(delay)
# release the resources and close the browser
driver.quit()
Error:
[18496:26080:0710/154847.346:ERROR:cert_verify_proc_builtin.cc(1051)] CertVerifyProcBuiltin for accounts.google.com failed:
----- Certificate i=1 (CN=Selenium Wire CA) -----
ERROR: No matching issuer found
[18496:26080:0710/154858.006:ERROR:cert_verify_proc_builtin.cc(1051)] CertVerifyProcBuiltin for optimizationguide-pa.googleapis.com failed:
----- Certificate i=1 (CN=Selenium Wire CA) -----
ERROR: No matching issuer found
[18496:26080:0710/154901.464:ERROR:cert_verify_proc_builtin.cc(1051)] CertVerifyProcBuiltin for www.googletagmanager.com failed:
----- Certificate i=1 (CN=Selenium Wire CA) -----
ERROR: No matching issuer found
[18496:26080:0710/154905.509:ERROR:cert_verify_proc_builtin.cc(1051)] CertVerifyProcBuiltin for www.google-analytics.com failed:
----- Certificate i=1 (CN=Selenium Wire CA) -----
ERROR: No matching issuer found
Also, my task manager shows multiple Chrome tasks/windows open even after my window closes, causing my system to hang after a few runs of this code.
New contributor
Gaurang Tandon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.