我尝试在chrome中使用代理,但是, 我收到了这个错误。
driver = webdriver.Chrome(proxy=proxy)
TypeError: __init__() got an unexpected keyword argument 'proxy'
这是我尝试使用的代码 但它只适用于FireFox,所以我想知道是否有可能用phatom JS和chrome做到这一点
from selenium.webdriver.common.proxy import *
from selenium import webdriver
myProxy = "31.28.244.230:41905"
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy': '' # set this value as desired
})
driver = webdriver.Chrome(proxy=proxy)
driver.get("http://ipchicken.com/")
答案 0 :(得分:0)
尝试这样做
from selenium import webdriver
PROXY = "23.23.23.23:3128" # IP:PORT or HOST:PORT
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=http://%s' % PROXY)
chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.get("http://whatismyipaddress.com")
答案 1 :(得分:0)
from selenium import webdriver
PROXY = "31.28.244.230:41905"
webdriver.DesiredCapabilities.CHROME['proxy']={
"httpProxy":PROXY,
"ftpProxy":PROXY,
"sslProxy":PROXY,
"noProxy":None,
"proxyType":"MANUAL",
"autodetect":False
}
driver = webdriver.Chrome()
driver.get('http://www.whatsmyip.org/')