I’m currently working on a scraping project and facing some issues with using a proxy from Webshare. This is my first time using a proxy, and I can’t seem to access the target webpage. The webpage is HTTPS, while the proxy provided by Webshare uses HTTP.
Every time I try to open the webpage, I encounter an ERR_TUNNEL_CONNECTION_FAILED error. I’ve tried various methods, including writing custom Chrome extensions to handle the authentification, but nothing seems to work.
Help!
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.proxy import Proxy, ProxyType
proxy_ip_port = "here is my proxyip:here is my proxyport"
proxy_user = "xxx"
proxy_pass = "xxx"
proxy = Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy.http_proxy = proxy_ip_port
proxy.ssl_proxy = proxy_ip_port
options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=http://' + proxy_ip_port)
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_argument('--allow-insecure-localhost')
PATH = Service(executable_path="C:\Program Files (x86)\chromedriver.exe")
options.add_argument('--proxy-auth='+proxy_user+':'+proxy_pass)
driver = webdriver.Chrome(service=PATH, options=options)
driver.get("https://examplepage/12394")
alert = driver.switch_to.alert
alert.send_keys(f"{proxy_user}{webdriver.common.keys.Keys.TAB}{proxy_pass}")
alert.accept()
driver.implicitly_wait(8)`
Joshua Petersen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.