How do I set a proxy for phantomjs/ghostdriver in python webdriver?

Below is the example of how to set proxy for PhantomJs in Python. You may change proxy type: socks5/http.

service_args = [
    '--proxy=127.0.0.1:9999',
    '--proxy-type=socks5',
    ]
browser = webdriver.PhantomJS('../path_to/phantomjs',service_args=service_args)

Leave a Comment