0

I am trying to access a url using proxy authentication whith username and password.

I have found a package which uses proxy authentication: selenium-wire on https://github.com/wkeeling/selenium-wire

I have written the following code

from seleniumwire import webdriver

df_proxies=WebShare_Proxies()
args=df_proxies.values[random.choice(df_proxies.index)].tolist()

proxy_ip,proxy_port,username,password=args

url='https://fra.privateinternetaccess.com/pages/whats-my-ip/'

proxyString=username+":"+password+"@"+str(proxy_ip)+":"+str(proxy_port)

options = {
'proxy': {
    'http': 'http://'+proxyString,
    'https': 'https://'+proxyString,
    'no_proxy': 'localhost,127.0.0.1'
    }
}

driver = webdriver.Firefox(seleniumwire_options=options)

WebShare_Proxies() calls https://www.webshare.io/ API to get my proxies list My proxy uses username and password for authentication

proxyString
'$myusername:[email protected]:8746'

I am having the following error when calling webdriver.Firefox(seleniumwire_options=options)

...in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

Anyone has a clue how to overcome this error ?

Thank you for you consideration

1 Answer 1

1

i think you misunderstood what seleniumwire is

seleniumwire is a package that enables you to inspect requests made by selenium as if you were inside chrome dev tools it does this by running a mitmproxy instance and proxying requests through it

mitmproxy is a debugging proxy that sits between a client (in this case selenium instance) and internet and allows you to intercept modify and inspect requests made by the client you cant use more than 2 proxies with selenium so in order to use your own proxy you need to use a regular selenium instance

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
a = "proxyaddress:port:user:password"
chrome_options.add_argument('--proxy-server=:{}'.format(a))
driver = webdriver.Chrome(options=chrome_options)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.