D
D
D55RUS2021-07-22 19:52:53
Python
D55RUS, 2021-07-22 19:52:53

How to use proxy with authorization in selenium?

I have this code:

import os
from seleniumwire import webdriver

import json


class Starting:
    def __init__(self):
        self.proxy = f"http://C0HDCd:[email protected]:8000"  


    def driver_load(self):
        options = webdriver.ChromeOptions()
        options.add_argument(f'user-data-dir={os.getcwd()}')  # data[cookies] load

        proxy = {
            "proxy": {
                "https": self.proxy
            }
        }

        return webdriver.Chrome(executable_path=f'{os.getcwd()}/chromedriver.exe',
                                seleniumwire_options=proxy)

    def start(self):
        driver = self.driver_load()
        driver.get('https://myip.ru/')


If I run it like this, then I run a pure chrome browser, without a previously saved profile, although I wrote options.add_argument(f'user-data-dir={os.getcwd()}').
But if I write like this: webdriver.Chrome(executable_path=f'{os.getcwd()}/chromedriver.exe',
seleniumwire_options=proxy,
options=options), then the proxies just stop working, BUT the chrome profile works.
How to make proxy work with authorization and save the chrome profile?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question