I tested a script with Selenium Python to retrieve information from a web page. It works, at least until my IP is found. I would like to try using a proxy. I have tried the following two alternatives.
First way:
PROXY = "176.31.68.252:20213"
webdriver.DesiredCapabilities.CHROME['proxy'] = {
"httpProxy": PROXY,
"ftpProxy": PROXY,
"sslProxy": PROXY,
"noProxy": None,
"proxyType": "MANUAL",
"class": "org.openqa.selenium.Proxy",
"autodetect": False
}
url = 'https://www.ufficiocamerale.it/'
driver = webdriver.Chrome(desired_capabilities=webdriver.DesiredCapabilities.CHROME)
wait = WebDriverWait(driver, 20)
driver.get(url)
# rest of the code
Second way:
PROXY = "176.31.68.252:20213"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=https://%s' % PROXY)
url = 'https://www.ufficiocamerale.it/'
driver = webdriver.Chrome(chrome_options=chrome_options)
wait = WebDriverWait(driver, 20)
driver.get(url)
# rest of the code
But in the first case the webpage returns the error ERR_EMPTY_RESPONSE and in the second case it returns the error ERR_TIMED_OUT.
I found the proxy in an online free proxy list.
Is this a problem with my chosen proxy? Or is it a code problem? What is the standard way to proceed in these cases?