Answer the question
In order to leave comments, you need to log in
How to set proxy in selenium?
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
import names
import random
chars = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
chars1 = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
proxy = "62.33.207.201"
port = "80"
while True:
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", proxy)
profile.set_preference("network.proxy.http_port", port)
profile.set_preference("network.proxy.ssl", proxy)
profile.set_preference("network.proxy.ssl_port", port)
profile.update_preferences()
driver = webdriver.Firefox(executable_path="C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python37-32\\geckodriver.exe", firefox_profile=profile)
driver.get("https://www.iplocation.net/find-ip-address")
if __name__ == "__main__":
unittest.main()
Answer the question
In order to leave comments, you need to log in
proxy = '62.33.207.201:80'
caps = webdriver.DesiredCapabilities.FIREFOX
caps['marionette'] = True
caps['proxy'] = {
"proxyType": "MANUAL",
"httpProxy": proxy,
"ftpProxy": proxy,
"sslProxy": proxy
}
driver = webdriver.Firefox(capabilities=caps)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question