2016-08-29 3 views
0

Ich versuche Code mit Python Selen laufenIP-Adresse ändern Python Selenium

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() 

Aber meine IP-Adresse ändert sich nicht, wenn Sie diese Datei ausführen.

Wie kann ich meine IP-Adresse ändern. Ich entwickle einen Web-Crawler und muss die IP ändern

Antwort

0

Verwenden Sie die gewünschten Funktionen für 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