IP is a string in the same format as "182.90.80.137:8123"
Firefox browser:
IP_IP = Ip.split (":") [0]
ip_port = Int (Ip.split (":") [1])
print (IP_IP)
print (ip_port)
Random_header = Random.choice (HEADERS)
webdriver. desiredcapabilities.firefox[' firefox.page.settings.userAgent ' = Random_header profile
= Webdriver. Firefoxprofile ()
profile.set_preference (' Network.proxy.type ', 1) # Default 0, is direct connection; 1 is manual proxy configuration.
profile.set_preference (' network.proxy.http ', ip_ip)
profile.set_preference (' Network.proxy.http_port ', Ip_port)
profile.set_preference (' Network.proxy.ssl ', ip_ip)
profile.set_preference (' Network.proxy.ssl _port ', Ip_port)
profile.update_preferences ()
driver = Webdriver. Firefox (Profile)
Google Chrome
Chromedriver = ' C:/Program Files (x86)/google/chrome/application/chromedriver.exe '
chome_options = Webdriver. Chromeoptions ()
chome_options.add_argument (('--proxy-server=http://' + IP))
os.environ[" Webdriver.chrome.driver "] = chromedriver
Driver = webdriver. Chrome (Chromedriver, chrome_options=chome_options)