PYTHON - selenium proxy configuration

-1

I'm trying to implement proxy configuration in firefox via selenium but when I open the page, setup works. Here is the test I did to access a site that verifies the ip.

profile = webdriver.FirefoxProfile()
profile.set_preference('general.useragent.override', random.choice(uas))
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http",PROXY_HOST)
profile.set_preference("network.proxy.http_port",int(PROXY_PORT))

driver = webdriver.Firefox(firefox_profile=profile)
driver.set_page_load_timeout(30)
try:

driver.get('https://httpbin.org/ip')
time.sleep(30)
driver.quit()
except:
driver.quit()

Could you help me solve this problem? Is the configuration I made wrong? Thanks in advance!

    
asked by anonymous 11.04.2018 / 23:59

1 answer

0

Hello,

I was testing and I got it, maybe it's the SSL option.

IPS = ('192.168.0.1:81','192.168.0.2:82')
myProxy = random.choice(IPS)

proxy = myProxy.split(':')[0]
port = int(myProxy.split(':')[1])
print(proxy)
print(port)

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)
driver = webdriver.Firefox(firefox_profile=profile)

driver.get('http://www.whatsmyip.org')
content = driver.find_element_by_id('ip').txt
print(content)
driver.quit()
    
02.09.2018 / 18:45