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.71k stars 1.14k forks source link

How to use UC with chrome portable? #641

Open luan1412167 opened 2 years ago

luan1412167 commented 2 years ago

Hey, thanks for great repo, Because UC downloads driver is slow, I want to use Chromeportable.exe for driver. I'm setting options.binary_location = Chromeportable_exe_path. Code is run fine but browser cannot close while my code closed. Can you help me fix it? Thanks so much

sebdelsol commented 2 years ago

binary_location argument specify the browser path not the driver path.

hasansezertasan commented 2 years ago

Hi, 👋 I recently needed to use a portable chrome and spend many times and got figured it out.

I used some different resources and managed to make it work.

My guide:

Here is my boilerplate code! app.py

import os

from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import undetected_chromedriver.v2 as undetected_chromedriver

options = Options()

# For portable setup
service = Service(os.getcwd() + "\\GoogleChromePortable\\chromedriver.exe") # Chromedriver path
options.binary_location = os.getcwd() + "\\GoogleChromePortable\\App\\Chrome-bin\\chrome.exe"  # Portable Chrome path
options.add_argument("user-data-dir=" +  os.getcwd() + f"\\GoogleChromePortable\\Data\\profile") # Portable Profiles, UC opens the last used profile

driver = undetected_chromedriver.Chrome(
    service = service,
    options = options,
    version_main = 90,
)

Additional note, you don't need to add the "user-data-dir" argument, this is just how I use it.

Hope it'll help, 👋

brrrada commented 1 year ago

I managed to make it work by downgrading to selenium 4.9.