B
B
Bergis2021-05-16 22:09:46
Python
Bergis, 2021-05-16 22:09:46

How to use proxy with selenium?

Tell me how you can add a proxy for selenium?
I am trying to use this code:

PROXY = "прокси"
  firefox_options = webdriver.FirefoxOptions()
  firefox_options.add_argument('--proxy-server=%s' % PROXY)

  profile = webdriver.FirefoxProfile()
  profile.set_preference('intl.accept_languages', 'en-US, en')
  binary = FirefoxBinary(r'C:\\Program Files\\Mozilla Firefox\\firefox.exe')
  driver = webdriver.Firefox(firefox_binary=binary, executable_path='C:\\geco\\geckodriver.exe',firefox_profile=profile, firefox_options=firefox_options)

Then I go to the site 2ip
browser = driver.get(" https://2ip.ru/ ")
and I see that the proxy has not changed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
potapovdmtriy, 2021-05-16
@Bergis

browser_options = Options()
    browser_options.add_argument('--proxy-server=http://%s' % proxy)

    browser = webdriver.Chrome(options=browser_options)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question