2023年7月3日发(作者:)
selenium代理IP验证⽤户名密码⽅法详解默认情况下,Chrome的–proxy-server=":port"参数不⽀持设置⽤户名和密码认证。但在启动代理IP时⼤多数会遇到需要通过⽤户名和密码验证来添加代理,本博客就遇到了这样的问题,查阅资料后,对整个思路做了⼀个封装,与⼤家共勉第⼀步:新建 ⽂件,复制如下代码var config = { mode: "fixed_servers", rules: { singleProxy: { scheme: "http", host: "mimvp_proxy_host", port: parseInt(mimvp_proxy_port) }, bypassList: [""] } };
({value: config, scope: "regular"}, function() {});
function callbackFn(details) { return { authCredentials: { username: "mimvp_username", password: "mimvp_password" } };}
tener( callbackFn, {urls: [""]}, ['blocking']);第⼆步:新建 ⽂件,复制如下代码{ "version": "1.0.0", "manifest_version": 2, "name": "Chrome Proxy", "permissions": [ "proxy", "tabs", "unlimitedStorage", "storage", "", "webRequest", "webRequestBlocking" ], "background": { "scripts": [""] }, "minimum_chrome_version":"22.0.0"}第⼆步:创建⼀个 Chrome-proxy-helper ⽂件夹,将 和 放⼊其中第三步:插件制作# 创建⼀个zip⽂件zf = e(extension_file_path, mode='w')((_PROXY_HELPER_DIR, ''), '')# 替换模板中的代理参数,⽣成插件background_content = open((_PROXY_HELPER_DIR, '')).read()background_content = background_e('%proxy_host', ip)background_content = background_e('%proxy_port', port)background_content = background_e('%username', username)background_content = background_e('%password', password)tr('', background_content)()第四步:通过 _extension() ⽅法将⽣成的插件传⼊即可_extension('插件名字')如果你不想⾃⼰总结,我已经封装好代码,直接下载调⽤即可,下载地址:
发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1688383467a129830.html
评论列表(0条)