2016-08-29 15 views
0

は、私は、Pythonセレン変更IPアドレスのPythonセレン

from selenium import webdriver 
import time 

profile = webdriver.FirefoxProfile() 
profile.set_preference("network.proxy_type",1) 
profile.set_preference("network.proxy.http","124.240.187.80") 
profile.set_preference("network.proxy.http_port",82) 
profile.update_preferences() 

driver=webdriver.Firefox(firefox_profile=profile) 
driver.get('https://www.whatismyip.com/') 
driver.sleep(3) 
driver.close() 

でコードを実行してみてくださいしかし、あなたはこのファイルを実行すると、私のIPアドレスは変更されません。

どのように私のIPアドレスを変更できますか。私はWebクローラーを開発しており、IPを変更する必要があります。

答えて

0

FF用の機能を使用してください。

proxy = "124.240.187.80:82" 

webdriver.DesiredCapabilities.FIREFOX['proxy'] = { 
    "httpProxy":proxy, 
    "ftpProxy":proxy, 
    "sslProxy":proxy, 
    "noProxy":None, 
    "proxyType":"MANUAL", 
    "class":"org.openqa.selenium.Proxy", 
    "autodetect":False 
} 

WebDriver: Advanced Usage - proxy

関連する問題