You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
Problem behavior:
The dynamic switching of upstream proxy is properly functioning without the flag '--ignore-certificate-error' for a driver instantiation. I simply use driver.proxy = {'http': 'new_proxy'}, and the next driver.get() will be using the new proxy IP. However, without this flag, the accesses to webpages will be blocked by the invalid certificate error raised by Chrome. We tried some other methods but they failed to bypass this warning, (e.g., --ignore-ssl-errors=yes, --allow-insecure-localhost, --allow-running-insecure-content, etc.).
If we add the flag --ignore-certificate-error to Chrome, the warning is gone and webpage access is normal. But in this case, the proxy switching will not work if we change the value of driver.proxy to {'http': 'new_proxy'} or to an empty dict {}. Even though their values were indeed changed, they did not become effective in subsequent navigations.
Any advice would be much appreciated!
A sample of my code:
importseleniumwire.undetected_chromedriverasucfromselenium.webdriverimportChrome, DesiredCapabilitiesfromselenium.webdriver.chrome.optionsimportOptionsfromcommonimportPROXY_USERNAME, PROXY_PASSWORD, PROXY_HOST, PROXY_PORT# Get proxy for session 12345seleniumwire_options= {
"proxy": {
"http": f"http://{PROXY_USERNAME}-session-{12345}:{PROXY_PASSWORD}@{PROXY_HOST}:{PROXY_PORT}",
"https": f"http://{PROXY_USERNAME}-session-{12345}:{PROXY_PASSWORD}@{PROXY_HOST}:{PROXY_PORT}",
"verify_ssl": False,
},
}
# Add flag and configchrome_options=uc.ChromeOptions()
chrome_options.add_argument('--ignore-certificate-errors')
capabilities=DesiredCapabilities.CHROME.copy()
capabilities["acceptInsecureCerts"] =True# Instantiate a driverdriver=uc.Chrome(
options=chrome_options,
desired_capabilities=capabilities,
seleniumwire_options=seleniumwire_options,
)
# Check current proxy sessionprint(driver.proxy)
# Check current IP addressdriver.get("http://lumtest.com/myip.json")
print(driver.page_source)
# Swap to a new proxy session 54321 (given a new IP)driver.proxy= {"http": f"http://{PROXY_USERNAME}-session-{54321}:{PROXY_PASSWORD}@{PROXY_HOST}:{PROXY_PORT}"}
# Check the new proxy IPprint(driver.proxy)
driver.get("http://lumtest.com/myip.json")
print(driver.page_source)
The text was updated successfully, but these errors were encountered:
Problem behavior:
The dynamic switching of upstream proxy is properly functioning without the flag '
--ignore-certificate-error
' for a driver instantiation. I simply usedriver.proxy = {'http': 'new_proxy'}
, and the nextdriver.get()
will be using the new proxy IP. However, without this flag, the accesses to webpages will be blocked by the invalid certificate error raised by Chrome. We tried some other methods but they failed to bypass this warning, (e.g.,--ignore-ssl-errors=yes
,--allow-insecure-localhost
,--allow-running-insecure-content
, etc.).If we add the flag
--ignore-certificate-error
to Chrome, the warning is gone and webpage access is normal. But in this case, the proxy switching will not work if we change the value ofdriver.proxy
to{'http': 'new_proxy'}
or to an empty dict{}
. Even though their values were indeed changed, they did not become effective in subsequent navigations.Any advice would be much appreciated!
A sample of my code:
The text was updated successfully, but these errors were encountered: