【问题标题】:How do i set proxy for ie in python webdriver?如何在 python webdriver 中为 ie 设置代理?
【发布时间】:2015-12-31 02:18:22
【问题描述】:

我正在使用此代码:

profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", "proxy.server.address")
profile.set_preference("network.proxy.http_port", "port_number")
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)

在 python webdriver 中为 FireFox 设置代理。这适用于火狐。如何在ie中设置这样的代理?

【问题讨论】:

    标签: python selenium proxy webdriver


    【解决方案1】:

    我知道这是一个老问题,但我是这样做的:

    caps = DesiredCapabilities.INTERNETEXPLORER.copy()
    caps["proxy"] = { "proxyType": "manual", "httpProxy": "localhost:8086" }
    driver = webdriver.Ie(capabilities = caps)
    

    如果您使用的是 browsermob 代理(就像我一样),它看起来像这样:

    server.start()
    proxy = server.create_proxy()
    caps = DesiredCapabilities.INTERNETEXPLORER.copy()
    caps["proxy"] = { "proxyType": "manual", "httpProxy": proxy.proxy }
    driver = webdriver.Ie(capabilities = caps)
    

    【讨论】:

      【解决方案2】:

      使用:

      webdriver.Ie
      

      请参阅http://selenium-python.readthedocs.org/api.html,您必须为 selenium 安装 Internet Explorer 的 webdriver 才能使用它

      【讨论】:

      • 是的,我知道如何使用此代码启动 IE,但我不知道如何为 IE 设置代理。
      • 乔说的。这会启动 IE,但不指示如何为 IE 设置代理(顺便说一下,它只是系统代理......除非你使用的是 selenium 服务器,否则这是另一个球游戏)这是原始问题所问的.
      猜你喜欢
      • 2012-07-12
      • 2013-01-19
      • 2020-08-07
      • 2019-04-04
      • 2019-01-19
      • 1970-01-01
      • 2015-03-19
      相关资源
      最近更新 更多