V
V
Voprosium2021-08-25 18:15:53
Python
Voprosium, 2021-08-25 18:15:53

How to login to selenium proxy?

Good evening everyone! I have a problem with adding proxy in selenium.
I work with Chrome. I looked at many options on the Internet, but nothing helped, so I came here.
Here's what I've tried:

  • Use selenium-wire
  • Use
    # ...
    options = webdriver.ChromeOptions()
    options.add_extension('proxy.zip')
    # ...


  • Use
    driver = webdriver.Chrome(executable_path='path to chromedriver.exe')
    alert = driver.switch_to_alert
    alert.send_keys(login, Keys.TAB, password)
    alert.accept()

  • And also tried withwebdriver.DesiredCapabilities.CHROME

But none of this works for some reason.
  • The problem with selenium-wire is that the program has authorized itself in the proxy, but the proxy itself is not working.
  • The problem in the second paragraph is that an error appears that the proxy is not working
  • The problem in the third paragraph is that it cannot find alert
  • The problem is in the fourth paragraph, authorization is needed))

The only method where the proxy works is the fourth, but authorization is needed :(

I hope I explained everything in detail, if something is not clear, ask questions, I will be happy to answer.

Thank you for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
UberPool, 2021-08-26
@UberPool

from selenium import webdriver
from seleniumwire import webdriver
from webdriver_manager.chrome import ChromeDriverManager

username = ''
password = ''
ip = ''
port = ''
 
proxy = f'{username}:{password}@{ip}:{port}'
options = {
    'proxy': {
        'https': f'https://{proxy}',
    }
}

driver = webdriver.Chrome(ChromeDriverManager().install(),seleniumwire_options=options)

driver.get('https://2ip.ru/')

Fixed spaces

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question