ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.98k stars 1.16k forks source link

no driver, looking for proxies solution #1845

Open Drey7k opened 6 months ago

Drey7k commented 6 months ago

hello, I want to use proxies list from a txt (ip:port:user:pass) for a simple ATC script, I am looking for an exemple because I tried tons of things and spent 2 days without any result. Have a good day

b-nnett commented 6 months ago

https://stackoverflow.com/questions/55582136/how-to-set-proxy-with-authentication-in-selenium-chromedriver-python

Check the accepted answer.

Drey7k commented 6 months ago

https://stackoverflow.com/questions/55582136/how-to-set-proxy-with-authentication-in-selenium-chromedriver-python

Check the accepted answer.

thanks but already tried and not working

oculunto commented 6 months ago

Any idea how to make it work ? I cannot seem to be able to load the extension that I create into the no driver chrome browser. I have tried with config.add_extension=extensionDir , config.add_argument = r'--load-extension='+extensionDir , and browser = await uc.start(browser_args=['--load-extension='+extensionDir]) and none of them loads the extension properly (manifest + json), which works properly on the old undetected-chrome. The config argument for a data_dir for example works properly, but not for extensions.

develfe commented 6 months ago

Any idea how to make it work ? I cannot seem to be able to load the extension that I create into the no driver chrome browser. I have tried with config.add_extension=extensionDir , config.add_argument = r'--load-extension='+extensionDir , and browser = await uc.start(browser_args=['--load-extension='+extensionDir]) and none of them loads the extension properly (manifest + json), which works properly on the old undetected-chrome. The config argument for a data_dir for example works properly, but not for extensions.

I have the same problem with NoDriver. It is interesting to note that this appears under Centos, but under Windows 10 it works fine. nodriver 0.29rc2 Python 3.12.3 undetected-chromedriver 3.5.5 Google Chrome 124.0.6367.118

oculunto commented 6 months ago

That's weird, I'm on windows 10 and it does not work. I tried using manifest v2 and v3 to no avail. I tried opening a window and then loading the extension manually, and it does work though.

develfe commented 6 months ago

MANIFEST.JSON and BACKGROUND.JS:

{
    "version": "1.0.0",
    "manifest_version": 2,
    "name": "Proxies",
    "permissions": [
        "proxy",
        "tabs",
        "unlimitedStorage",
        "storage",
        "<all_urls>",
        "webRequest",
        "webRequestBlocking"
    ],
    "background": {
        "scripts": ["background.js"]
    },
    "minimum_chrome_version":"22.0.0"
}
develfe commented 6 months ago
var config = {
        mode: "fixed_servers",
        rules: {
        singleProxy: {
            scheme: "http",
            host: "X.X.X.X",
            port: parseInt(X)
        },
        bypassList: ["localhost"]
        }
    };

chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});

function callbackFn(details) {
    return {
        authCredentials: {
            username: "xxxxxx",
            password: "xxxxxx"
        }
    };
}

chrome.webRequest.onAuthRequired.addListener(
            callbackFn,
            {urls: ["<all_urls>"]},
            ['blocking']
);
oculunto commented 6 months ago

Yeah thanks, I have something like that yes, but no driver won't load it... i create both files and try to load them with the previously mentioned methods, but it doesn't load it. But if I open an uc no driver window, and go to extensions, I can select that same directory it created and it will load the extension well... (I have to enable developer mode before though...) Are you using no driver or undetected-chromedriver ? (in undetected it works just fine)

develfe commented 6 months ago

Proxy authorization with undetected-chromedriver works fine for me on both Centos and Windows 10. The problem is with NoDriver.

develfe commented 6 months ago

Apparently, I found the cause of the problem with NoDriver under Centos. The extension didn`t have time to load due to a rather slow VPS.

Solution:

Edit File: nodriver/core/browser.py

331: await asyncio.sleep(0.25) -> await asyncio.sleep(2.5)

It would be great to add this option to the settings.

oculunto commented 6 months ago

Did not work for me, but thanks for updating !

oculunto commented 6 months ago

Found a solution for mine, I was using add_extension wrong, the right way to do it is config1.add_extension(extensionDir) unlike user_data_diror browser_executable_path

therealpurplemana commented 1 month ago

Found a solution for mine, I was using add_extension wrong, the right way to do it is config1.add_extension(extensionDir) unlike user_data_diror browser_executable_path

FYI, passing a direct browser argument into nodriver does work correctly: f"--load-extension={ublock_extension_path}".