standorfall999 standorfall999 - 2 years ago 1224
Python Question

python selenium proxys in chrome/phantomjs

I've tried to use proxy s in chrome but,
I get this error.

driver = webdriver.Chrome(proxy=proxy)
TypeError: __init__() got an unexpected keyword argument 'proxy'

This is the code I am trying to use
but it only works with FireFox, so I was wondering if it is possible to do this with phatom JS and chrome

from selenium.webdriver.common.proxy import *
from selenium import webdriver
myProxy = ""

proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy': '' # set this value as desired

driver = webdriver.Chrome(proxy=proxy)


Answer Source

Try doing it like this

from selenium import webdriver


chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=http://%s' % PROXY)

chrome = webdriver.Chrome(chrome_options=chrome_options)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download