from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from w3lib.http import basic_auth_header

proxy = "proxy.crawlera.com:8010"
username = "<API_KEY>"
password = ""

service_args = [
    "--ignore-ssl-errors=true",
    "--ssl-protocol=any",
    "--proxy={}".format(proxy),
    "--proxy-type=http",
]

caps = DesiredCapabilities.PHANTOMJS
authentication_token = basic_auth_header(username, password).decode('utf-8')
caps['phantomjs.page.customHeaders.Proxy-Authorization'] = authentication_token

driver = webdriver.PhantomJS(
    service_args=service_args,
    desired_capabilities=caps,
    executable_path="/path/to/phantomjs"
)
driver.get("https://www.whatismyip.com/")
driver.set_window_size(1024, 768)
driver.save_screenshot('screen.png')
driver.close()