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.91k stars 1.16k forks source link

Cannot add Extension to chrome V2 #154

Closed canonsky1992 closed 3 years ago

canonsky1992 commented 3 years ago

chrome_options = Options() chrome_options.add_argument('user-data-dir='+profiles[i]) chrome_options.add_extension('data/exten.crx') driver = uc.Chrome(options=chrome_options) Why v2 cannot add extension?

rnyPlanet commented 3 years ago

@ultrafunkamsterdam hi thanks for chromedriver. I also cannot add an extension. Is this a bug? @ultrafunkamsterdam extensions work for you?

ultrafunkamsterdam commented 3 years ago

No. Extensions do not work in combination with remote debugging (which is used by this module).

rnyPlanet commented 3 years ago

got it. maybe there is some way out to add auth proxy? (I tried seleniumwire - there is a problem with mitmproxy that changes fingerprint and cloudflare returns 503 error. I also thought about an extension that would help with a proxy - but remote debugging does not work with the extension). you have more knowledge - is there any way out? v2 works fine, but damn I need to work with auth proxy

ultrafunkamsterdam commented 3 years ago

Fingerprint is not a network thing so mitm proxy wouldn't change it. That's for sure 😉

rnyPlanet commented 3 years ago

well i don't have enough knowledge, and i read this there mitm and selenium-wire.

rnyPlanet commented 3 years ago

no solutions at all?( What happens if remove remote debugging? won't bypass cloudflare? (remove for the ability to install extensions with auth proxy)

rnyPlanet commented 3 years ago

@ultrafunkamsterdam Sorry to bother you, I guess I'm already bored you) I found a couple of possibilities 1 and 2 (use --load-extension to load the extension for the remote debugging browser, this line with arguments), I tried but got an error ERR_SOCKS_CONNECTION_FAILED. I wanted to ask if you tried this? if not, is there a chance that it will help?

ultrafunkamsterdam commented 3 years ago

You can definitly add extensions. But you'll need a steady profile as extensions are kept in the profile.

image

the-white-light commented 3 years ago

I've managed to load extensions by extracting the CRX file into a folder and then using --load-extension.

vancouverjackluo commented 2 years ago

I've managed to load extensions by extracting the CRX file into a folder and then using --load-extension.

Hello @the-white-light , can you elaborate how you approached it with --load-extension? I have the following code, doesn't work: options.add_argument('--load-extension = C:\Code\project_MP\ABC.crx')

vancouverjackluo commented 2 years ago

Can you kindly explain in detail how this works? a sample code will be much appreciated.

Thanks

the-white-light commented 2 years ago

You had it mostly right, but as I said before you need to extract the extension first, then direct the code to the destination folder.

I extracted the .crx file to ./MultiPass and then did opt.add_argument('--load-extension=./MultiPass')

vancouverjackluo commented 2 years ago

You had it mostly right, but as I said before you need to extract the extension first, then direct the code to the destination folder.

I extracted the .crx file to ./MultiPass and then did opt.add_argument('--load-extension=./MultiPass')

@the-white-light yes, I have extracted the extension into .crx file and saved in the same directory(folder): options.add_argument('--load-extension = ./ABC.crx')

tried it...still doesn't work. Here is my entire code:

import undetected_chromedriver as uc import time from selenium import webdriver from selenium.webdriver.common.by import By

def main(): options = uc.ChromeOptions() options.add_argument("--no-sandbox --no-first-run --no-service-autorun --password-store=basic") driver = uc.Chrome(options=options) options.add_experimental_option('excludeSwitches', ['enable-logging']) options.add_argument('--load-extension = ./abc.crx')

if name == 'main': main()

the-white-light commented 2 years ago

Please re-read what I wrote. You need to extract the crx, and it is not used in the code. You downloaded the crx file, which is basically just a zip file. Extract it then point your code to the destination folder.

vancouverjackluo commented 2 years ago

Please re-read what I wrote. You need to extract the crx, and it is not used in the code. You downloaded the crx file, which is basically just a zip file. Extract it then point your code to the destination folder.

did that.

the-white-light commented 2 years ago
  1. No you didn't. You still are using the crx file in your code, see the line I posted — no crx.
  2. You added it to options after initializing the chromedriver, it needs to be before the driver = line.
vancouverjackluo commented 2 years ago

2. er initializing the chro

@the-white-light thanks, my mistake. does the .crx file needs to be the only file in the subfolder?

the-white-light commented 2 years ago

No, you just extract it into a folder and point your code to that.

vancouverjackluo commented 2 years ago

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else

image

90xboy commented 2 years ago

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else

image

hey mate, did you solve this error? i also can not add extension.

dafriyie commented 2 years ago

I know it's late to add this comment but it might help someone in the future. When you extract the extension, point your code to the full path of the extracted folder like C:\Users\yourproject\extension It worked for me!!!

ribonred commented 2 years ago

i found the soultion of this

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else image

hey mate, did you solve this error? i also can not add extension.

i got the solution using this.. try download the extension as zip.. then extract to some folder

then you can options.add_argument('--load-extension = ./extraction_folder')

should not .crx file

90xboy commented 2 years ago

i found the soultion of this

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else image

hey mate, did you solve this error? i also can not add extension.

i got the solution using this.. try download the extension as zip.. then extract to some folder

then you can options.add_argument('--load-extension = ./extraction_folder')

should not .crx file

hi mate, i can kindly share a sample code, i try but still get error. I newbie in python selenium, tks for your help Here my code: from selenium.webdriver.common import keys import undetected_chromedriver.v2 as uc import time if name == 'main': options = uc.ChromeOptions() options.add_argument("--disable-notifications") options.add_argument('--load-extension =C:\python\myproject\Extract file') # extract file zip to directory

setting profile

options.user_data_dir = "c:\\temp\\profile18"
driver = uc.Chrome(options=options,version_main=97)
time.sleep(2)
input('ok')
ribonred commented 2 years ago
ext
├── pass
│   ├── 47a1591dea3b6d1f42f9b3cd0673f69c.svg
│   ├── background.js
│   ├── icons
│   │   ├── 128
│   │   │   ├── gold.png
│   │   │   └── grey.png
│   │   ├── 32
│   │   │   ├── gold.png
│   │   │   └── grey.png
│   │   ├── 48
│   │   │   ├── gold.png
│   │   │   └── grey.png
│   │   └── 64
│   │       ├── gold.png
│   │       └── grey.png
│   ├── manifest.json
│   ├── popup.css
│   ├── popup.html
│   └── popup.js
└── solver
    ├── content
    │   ├── hcaptcha.js
    │   ├── model.js
    │   └── tf.js
    ├── images
    │   ├── icon_128.png
    │   ├── icon_16.png
    │   ├── icon_32.png
    │   └── icon_48.png
    ├── manifest.json
    ├── model
    │   ├── group1-shard1of5
    │   ├── group1-shard2of5
    │   ├── group1-shard3of5
    │   ├── group1-shard4of5
    │   ├── group1-shard5of5
    │   └── model.json
    └── worker.js

ext is root folder of extension.. inside ext folder pass and solver are extracted extension then load the extension like this

options.add_argument('--load-extension=./ext/solver,./ext/pass')

i use 2 extension here, so is separated by coma in argument

i found the soultion of this

No, you just extract it into a folder and point your code to that.

damn, found it, but got this error instead...the .crx file should be fine since I just used it in a headless browser test...let me try something else image

hey mate, did you solve this error? i also can not add extension.

i got the solution using this.. try download the extension as zip.. then extract to some folder then you can options.add_argument('--load-extension = ./extraction_folder') should not .crx file

hi mate, i can kindly share a sample code, i try but still get error. I newbie in python selenium, tks for your help Here my code: from selenium.webdriver.common import keys import undetected_chromedriver.v2 as uc import time if name == 'main': options = uc.ChromeOptions() options.add_argument("--disable-notifications") options.add_argument('--load-extension =C:\python\myproject\Extract file') # extract file zip to directory # setting profile options.user_data_dir = "c:\temp\profile18" driver = uc.Chrome(options=options,version_main=97) time.sleep(2) input('ok')