[nodriver] how can i use a socks5 proxy with authentication?
rex1de opened this issue · comments
i have tried this h
manifest_json = """
{
"version": "1.0.0",
"manifest_version": 3,
"name": "Chrome Proxy",
"permissions": [
"proxy",
"tabs",
"storage",
"webRequest",
"webRequestAuthProvider"
],
"host_permissions": [
"<all_urls>"
],
"background": {
"service_worker": "background.js"
},
"minimum_chrome_version": "22.0.0"
}
"""
background_js = """
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "http",
host: "%s",
port: parseInt(%s)
},
bypassList: ["localhost"]
}
};
chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
function callbackFn(details) {
return {
authCredentials: {
username: "%s",
password: "%s"
}
};
}
chrome.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["<all_urls>"]},
['blocking']
);
""" % (proxy_host, proxy_port, proxy_login, proxy_pass)
print(proxy_host, proxy_port, proxy_login, proxy_pass)
with open(os.path.join(extension_dir, 'manifest.json'), 'w') as f:
f.write(manifest_json)
with open(os.path.join(extension_dir, 'background.js'), 'w') as f:
f.write(background_js)
driver = await uc.start(browser_args=[f'--load-extension={extension_dir}'])
also tried every scheme, http(s), socks4, socks5
extension loads in, but i cant get to any website
proxy is working for sure
So, my solutuion:
create dir with proxy exstention
Then you do your stuff and before running you must add line
chrome_options.add_argument('--load-extension=./proxies_extension')
For more info you can check this repo, but i modified it before execution
https://github.com/Smartproxy/Selenium-proxy-authentication
Zip extension didn't work for me
I am trying out using pproxy as a proxy redirectory. so you connect with a http no auth proxy on your local host which communicates with the socks5 proxy with auth.
Its mentioned here - https://stackoverflow.com/questions/43312573/how-to-set-socks5-proxy-with-auth-for-chrome-in-selenium-python