6

I am adding chrome options this way and it works if I use proxy ip authentication.

    options = webdriver.ChromeOptions() 
    options.headless = True
    options.add_argument('--proxy-server=92.128.165.143:3399')
    driver = uc.Chrome(options=options)

However, I have a proxy with authentication in this format: http://username:password@91.92.128.165.143:3399

If I add it like

options.add_argument('--proxy-server=http://username:password@91.92.128.165.143:3399')

it doesn't work. How could I add it with username/password? This applies only to undetected chrome driver.

Deivydas Voroneckis
  • 1,973
  • 3
  • 19
  • 40

3 Answers3

0

Unfortunately at the moment there is only one way to authenticate with an undetected chromedriver.

import undetected_chromedriver.v2 as uc
import pyautogui
import time

PROXY_HOST = "PROXY_IP"
PROXY_PORT = 6893
PROXY_USER = "user"
PROXY_PASSWORD = "password"

chrome_options = uc.ChromeOptions()
chrome_options.add_argument(f'--proxy-server={PROXY_HOST}:{PROXY_PORT}')

driver = uc.Chrome(options=chrome_options)
driver.get('https://bing.com')

time.sleep(1)
pyautogui.typewrite(PROXY_USER)
pyautogui.press('tab')
pyautogui.typewrite(PROXY_PASSWORD)
pyautogui.press('enter')
NeoUKR
  • 21
  • 5
-2

I think Ive achieved it already by the help of selenium wire but it didnt work with kivy gui so for scripting you can carryon like this but if you wanna use with kivy then definitely you will get error

from ast import Try


from pathlib import Path
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.proxy import *
from seleniumwire import undetected_chromedriver as uc
from fake_useragent import UserAgent
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from pyclick import HumanClicker
import pyautogui
import time

clicked=False

hostname = "188.74.183.126"
port = "8395"
proxy_username = "wclmiemy"
proxy_password = "a9hoxl4phkzr"
chrome_options = {
    'proxy': {
        'http': f'http://{proxy_username}:{proxy_password}@{hostname}:{port}',
        'https': f'https://{proxy_username}:{proxy_password}@{hostname}:{port}',
        'no_proxy': 'localhost,127.0.0.1'
    }
}




def delete_cache(driver):
    driver.execute_script("window.open('')")  # Create a separate tab than the main one
    driver.switch_to.window(driver.window_handles[-1])  # Switch window to the second tab
    driver.get('chrome://settings/clearBrowserData')  # Open your chrome settings.
    pyautogui.click("clear_data.png")

if __name__ == '__main__':
    email = "moqaddasmehran5@gmail.com"
    password = "moqaddaszaheenzaheen"
    ua = UserAgent()
    userAgent = ua.random
    options = webdriver.ChromeOptions()
    
 
    options.add_argument(f'user-agent={userAgent}')
    # options.add_argument('--ignore-certificate-errors-spki-list')
    # # options.add_argument('--ignore-ssl-errors')
    options.add_argument("--disable-infobars")
    
    browser = uc.Chrome(
        driver_executable_path="chromedriver",
        seleniumwire_options=chrome_options,
        options=options,
        use_subprocess=True
    )
    browser.maximize_window()
    browser.get('https://www.youtube.com/watch?v=uPxkrGL0l7U')
    ```
this code is kind of messy but im in Hurry hope you will be able to modify you willa also get ssle that you need to import in chrome thats it you will defnitely get it

    
baibars313
  • 17
  • 3
-5

Use the following code to add proxy with username and password:

from selenium import webdriver

PROXY = "http://username:password@91.92.128.165.143:3399"

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)

driver = webdriver.Chrome(chrome_options=chrome_options)

edit:

I found this how to set proxy with authentication in selenium chromedriver python?

Carter McKay
  • 432
  • 2
  • 12