网上的解决办法:
一、
from selenium import webdriver profile = webdriver.FirefoxProfile() profile.set_preference('network.proxy.type', 1) profile.set_preference('network.proxy.http', 'proxy_url') profile.set_preference('network.proxy.http_port', 3128) profile.set_preference('network.proxy.ssl', 'proxy_url') profile.set_preference('network.proxy.ssl_port', 3128) profile.update_preferences() driver = webdriver.Firefox(profile)
myProxy = "http://149.215.113.110:70" proxy = Proxy({ 'proxyType': ProxyType.MANUAL, 'httpProxy': myProxy, 'ftpProxy': myProxy, 'sslProxy': myProxy, 'noProxy':'' }) self.driver = webdriver.Firefox(proxy=proxy)
PROXY = "149.215.113.110:70" webdriver.DesiredCapabilities.FIREFOX['proxy'] = { "httpProxy":PROXY, "ftpProxy":PROXY, "sslProxy":PROXY, "noProxy":None, "proxyType":"MANUAL", "class":"org.openqa.selenium.Proxy", "autodetect":False } # you have to use remote, otherwise you'll have to code it yourself in python to driver = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.FIREFOX)
profile = webdriver.FirefoxProfile() profile.set_preference("network.proxy.type", 1) profile.set_preference("network.proxy.http", "proxy.server.address") profile.set_preference("network.proxy.http_port", "port_number") profile.update_preferences() driver = webdriver.Firefox(firefox_profile=profile)