【问题标题】:Change IP Address Python Selenium更改 IP 地址 Python Selenium
【发布时间】:2017-01-05 21:02:17
【问题描述】:

我尝试使用 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()

但是当你运行这个文件时我的 IP 地址并没有改变。

如何更改我的 IP 地址。我正在开发网络爬虫,需要更改ip

【问题讨论】:

    标签: python selenium proxy web-crawler


    【解决方案1】:

    为 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

    【讨论】:

      猜你喜欢
      • 2021-08-19
      • 1970-01-01
      • 2018-07-04
      • 2018-01-18
      • 2019-01-31
      • 2016-11-17
      • 1970-01-01
      • 2015-05-05
      • 1970-01-01
      相关资源
      最近更新 更多