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
add_proxy(chrome_options, proxy=Proxy(proxy)) chrome_options.binary_location = "/usr/bin/google-chrome-stable" driver = webdriver.Chrome(options=chrome_options) return driver
1 Reply
Hey there,
I have slightly modified python-selenium template for Apify Actor:
Note that you have to install additional packages (selenium-wire + deps).
Please let me know if that solves your problem.
PS: I have asked the tooling team to add some examples to the python-templates so the next time you might find it there 😉