Adi*_*hra 8 python proxy selenium proxies selenium-chromedriver
我有IPV6代理需要用户名和密码才能工作,我有什么办法可以在ChromeDriver(Headerless)中使用这些代理用户名和密码.
代理格式 - ip_address:port username:password
如果没有,那么有什么方法可以使用这些代理更改我的系统ipv6地址,所以ChromeDriver默认采用系统IP地址.
您可以创建简单的扩展来设置代理并处理授权
的manifest.json
{
"manifest_version": 2,
"name": "Chrome Proxy Auth",
"version": "1.0.0",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": ["background.js"]
}
}
Run Code Online (Sandbox Code Playgroud)
background.js编辑host, port, username, password
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
host: "XXX.XXX.XXX.XXX",
port: parseInt(8888)
}
}
};
chrome.proxy.settings.set({
value: config,
scope: "regular"
}, function() {});
function callbackFunc(details) {
return {
authCredentials: {
username: "............",
password: "............"
}
};
}
chrome.webRequest.onAuthRequired.addListener(
callbackFunc, {
urls: ["<all_urls>"]
},
['blocking']
);
Run Code Online (Sandbox Code Playgroud)
.zip
然后在python脚本中添加两个文件到存档
options = Options()
options.add_extension('/path/top/extension.zip')
driver = webdriver.Chrome(options=options)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
470 次 |
最近记录: |