0
私はFirefoxを単独で実行し、エージェントを設定して正常に動作します。私はセレンを介してFirefoxを実行し、プロキシを設定しますが、動作しません!プロキシサーバーは同じです!Python + selenium + firefox proxyが動作しません
コード1:
from selenium import webdriver
from selenium.webdriver.common.proxy import *
use_proxy=agent_IP+':'+str(agent_Port)
_proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': use_proxy,
'ftpProxy': use_proxy,
'sslProxy': use_proxy,
'noProxy': None, # set this value as desired
"proxyType":"MANUAL",
"class":"org.openqa.selenium.Proxy",
"autodetect":False
})
browser = webdriver.Firefox(proxy=_proxy)
browser.get('https://www.google.com')
コード2:
from selenium import webdriver
profile = webdriver.FirefoxProfile()
# Direct = 0, Manual = 1, PAC = 2, AUTODETECT = 4, SYSTEM = 5
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.share_proxy_settings", True)
profile.set_preference("network.http.use-cache", False)
profile.set_preference("network.proxy.http", agent_IP)
profile.set_preference("network.proxy.http_port", int(agent_Port))
profile.set_preference('network.proxy.ssl_port', int(agent_Port))
profile.set_preference('network.proxy.ssl', agent_IP)
profile.set_preference("general.useragent.override","whater_useragent")
profile.update_preferences()
browser = webdriver.Firefox(firefox_profile=profile)
browser.get('https://www.google.com')
誰かが私を助けることができますか?
THX!
セレンを介してプロキシを設定した後、私はエージェントのセット内のファイアウォールで見つかった正しいマニュアルセットと同じです! –
あなたはこれを理解できましたか? – cph