setting up proxies in selenium
setting up proxies in selenium
September 11, 2023
this is a sample configuration of using proxies with IP authentication, using selenium and python.
sample code
CHROMEDRIVER_PATH = /path/to/chromedriver
PROXY = "23.23.23.23:3128" # IP:PORT
URL = 'https://example.com'
from seleniumwire import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
options = Options()
options.add_argument('--proxy-server=%s' % PROXY)
s = Service(CHROMEDRIVER_PATH)
driver = webdriver.Chrome(service=s, options=options)
driver.get(URL)
what if the connection is insecure?
install this certificate
- or get the certificate using:
python -m seleniumwire extractcert
after the certificate is installed,
- open chrome settings
- select “Privacy and Security”
- under “Advanced” setting, click “Manage device certificates”
- then, click “Trusted Root Certification Authority” -> “import”
- import the certificate you just have downloaded.
this will make the connection secure.