Skyhorse_tamerS
Apify & Crawlee7mo ago
1 reply
Skyhorse_tamer

selenium + Residential Proxies

Hi all,

I am rather stupid and need some help setting chrome_options in the Selenium Init to use residential proxies?

I've tested a few ways and chrome seems to ignore the proxy and use the host server ip.

Essentially i just do this:

def init(self, args, **kwargs) -> None:
super().init(
args, kwargs)

self.driver = self._init_driver()
.
.
.

def _init_driver(self):
chrome_options = Options()


arguments = [
"--headless=new",
"--no-sandbox",
"--disable-dev-shm-usage",
"--disable-gpu",
]
for arg in arguments:
chrome_options.add_argument(arg)

proxy = {
"host": "proxy.apify.com",
"port": "8000",
"username": "groups-RESIDENTIAL",
"password": "<>"
}

add_proxy(chrome_options, proxy=Proxy(
proxy))
chrome_options.binary_location = "/usr/bin/google-chrome-stable"
driver = webdriver.Chrome(options=chrome_options)


return driver
Was this page helpful?