I am trying to get selenium to use a proxy that will change at a certain point.
from seleniumwire import webdriver
def proxyManage():
proxyChange("test.com", "8000", "user1", "password1")
def proxyChange(host, port, username, password):
options = {
'proxy': {
'http': 'http://'+username+':'+password+'@'+host+':'+port,
'https': 'https://'+username+':'+password+'@'+host+':'+port,
}
}
PATH = "D:/Programming/undetectable chrome/chromedriver.exe"
browser = webdriver.Chrome(PATH, options=options)
browser.get("https://whatismyipaddress.com/")
proxyManage()
So I import seleniumwire as I am unsure how normal selenium uses proxies. Now when I try to run the program to test on the website if it works I get an error below,
Traceback (most recent call last):
File "D:ProgrammingPythonproxyTest.py", line 20, in <module>
proxyManage()
File "D:ProgrammingPythonproxyTest.py", line 6, in proxyManage
proxyChange("test.com", "8000", "user1", "password1")
File "D:ProgrammingPythonproxyTest.py", line 16, in proxyChange
browser = webdriver.Chrome(PATH, options=options)
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagesseleniumwirewebdriverrowser.py", line 97, in __init__
chrome_options.add_argument('proxy-bypass-list=<-loopback>')
AttributeError: 'dict' object has no attribute 'add_argument'
So first is there a way I can pass these arguments to proxyChange()
without the error. The idea is to have a counter in proxyManage()
and every time it runs it will move the next line in the proxy.txt file and then parse these arguments to proxyChange()
and hopefully it will update without the program closing again? Would be nice to multithread this.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…