2

I Try run code with 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()

But my IP address does not change when you run this file.

How can I change my ip address. I am developing a web crawler and need to change the ip

Lucas Lopes
  • 1,373
  • 3
  • 14
  • 23

1 Answers1

4

Use desired capabilities for 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

unickq
  • 1,497
  • 12
  • 18