phantomjs_path = '/usr/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs'


class NewService(PhantomJSService):

    def __init__(self, *args, **kwargs):
        service_args = kwargs.setdefault('service_args', [])
service_args += ['--proxy=localhost:8080', '--proxy-type=http']
super(NewService, self).__init__(*args, **kwargs)
webdriver.phantomjs.webdriver.Service = NewService
self.driver = webdriver.PhantomJS(phantomjs_path)
webdriver.phantomjs.webdriver.Service = PhantomJSService
How do I set a proxy for phantomjs/ghostdriver in python webdriver?