user:pass proxies with selenium
Asked Answered
S

2

5

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")
Scrutineer answered 20/9, 2017 at 19:23 Comment(0)
C
7

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

Cushy answered 20/9, 2017 at 20:19 Comment(0)
D
0

I used Proxy Auto Auth with head chrome successfully,but headless chrome is fail。

selenium.common.exceptions.WebDriverException: Message: unknown error: failed to wait for extension background page to load: chrome-extension://ggmdpepbjljkkkdaklfihhngmmgmpggp/_generated_background_page.html from unknown error: page could not be found: chrome-extension://ggmdpepbjljkkkdaklfihhngmmgmpggp/_generated_background_page.html

Decemvirate answered 24/9, 2019 at 3:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.