Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

user:pass proxies with selenium

What is the best/easiest way to use user authenticated proxies in a program? I currently have this but I need username and password to be already filled in when browser opens.

from selenium import webdriver
PROXY = "123.123.123.243:80"

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--proxy-server=http://{}".format(PROXY))

print(chrome_options.arguments)
chrome = webdriver.Chrome(executable_path="drivers/chromedriver",chrome_options=chrome_options)
chrome.get("https://www.ipinfo.io")
like image 838
fraser dale Avatar asked Sep 20 '17 19:09

fraser dale


1 Answers

You can achieve the same using a Proxy Auto auth plugin

from selenium import webdriver

options = webdriver.ChromeOptions()
PROXY = "185.136.232.243:80"
options.add_extension("~/Downloads/Proxy Auto Auth.crx")
options.add_argument("--proxy-server=http://{}".format(PROXY))

driver = webdriver.Chrome(chrome_options=options)

driver.get("chrome-extension://ggmdpepbjljkkkdaklfihhngmmgmpggp/options.html")

driver.find_element_by_id("login").send_keys("user")
driver.find_element_by_id("password").send_keys("password")
driver.find_element_by_id("retry").clear()
driver.find_element_by_id("retry").send_keys("2")


driver.find_element_by_id("save").click()

driver.get("http://tarunlalwani.com")

Download the extension using below extensions

https://chrome.google.com/webstore/detail/get-crx/dijpllakibenlejkbajahncialkbdkjc/related https://chrome.google.com/webstore/detail/proxy-auto-auth/ggmdpepbjljkkkdaklfihhngmmgmpggp?utm_source=gmail

like image 170
Tarun Lalwani Avatar answered Oct 21 '22 02:10

Tarun Lalwani