undetected_chromedriver  Cannot add Extension

Posted in :

發現,直接在selenium 裡使用 extension 的方法,在uc 裡無效。

import undetected_chromedriver as uc
chrome_options = uc.ChromeOptions()
chrome_options.add_extension(PATH_TO_EXTENSION.crx)
driver = uc.Chrome(options=chrome_options)

解法:
https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/154

先把 .crx 上傳到線上的網站,就可以轉換成 .zip 檔,然後再解壓縮成目錄,再套用下列語法:

options.add_argument(‘–load-extension = ./extraction_folder’)

如果需要載入多筆,使用逗號分隔:

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')

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *