本文介绍了用户:通过硒代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在程序中使用经过用户身份验证的代理的最佳/最简便方法是什么?我目前有这个,但是打开浏览器时我需要输入用户名和密码.

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")

推荐答案

您可以使用Proxy Auto auth插件实现相同的目的

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

这篇关于用户:通过硒代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 18:53