Loading... ### background.jsbackground.js ```bash var config = { mode: "fixed_servers", rules: { singleProxy: { scheme: "http", host: "你的ip", port: parseInt(端口) }, bypassList: ["foobar.com"] } }; chrome.proxy.settings.set({value: config, scope: "regular"}, function() {}); function callbackFn(details) { return { authCredentials: { username: "用户名", password: "密码" } }; } chrome.webRequest.onAuthRequired.addListener( callbackFn, {urls: ["all_urls"]}, ['blocking'] ); ``` ### manifest.jsonmanifest.json ```bash { "version": "1.0.0", "manifest_version": 2, "name": "Chrome Proxy", "permissions": [ "proxy", "tabs", "unlimitedStorage", "storage", "all_urls", "webRequest", "webRequestBlocking" ], "background": { "scripts": ["background.js"] }, "minimum_chrome_version":"22.0.0" } ``` **把background.js中替换为代理信息 manifest.json不变 然后打包成proxy.zip既可把background.js中替换为代理信息 manifest.json不变 然后打包成proxy.zip既可** ```python from selenium import webdriver from selenium.webdriver.chrome.options import Optionsdriverpath = '' chromeOptions = webdriver.ChromeOptions() chromeOptions.add_extension("proxy.zip") driver = webdriver.Chrome(driverpath, options=chromeOptions) driver.get("http://httpbin.org/ip") print(driver.page_source) driver.close() ``` 最后修改:2021 年 11 月 25 日 © 允许规范转载 赞 0 如果觉得我的文章对你有用,请随意赞赏