0

How to use proxy extension to change proxy after sometimes in selenium python ?

Currently I am using this code to add proxy by the help of an extension.But now need to modify this to change proxy after sometimes multiple time.I want to convert this extension code to sometihing like "Proxy Switcher ".

manifest_json = """
    {
        "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": "76.0.0"
    }"""
background_js = """
var config = {
    mode: "fixed_servers",
    rules: {
        singleProxy: {
            scheme: "http",
            host: "%s",
            port: %d
        },
        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']
);
"""
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Jan 22 '23 at 07:23
  • Does this answer your question? [How to dynamically change proxies in chrome driver](https://stackoverflow.com/questions/54911913/how-to-dynamically-change-proxies-in-chrome-driver) – kaliiiiiiiii Jun 28 '23 at 16:18

1 Answers1

0

Just use a loop like this:

arr = array('proxy1', 'proxy2')
for (element in arr):
    proxyip = element
n4zgu1
  • 11
  • 1
  • then I can't use webdriver command simultaneously. Here i want to run webdriver and after some time I want to change proxy to not detected. – Nime Molla Shuvo Jan 22 '23 at 08:50