【问题标题】:setting proxy in selenium in python for IE browser在 IE 浏览器的 python 中的 selenium 中设置代理
【发布时间】:2018-06-13 12:43:05
【问题描述】:

我的问题是关于在 IE 浏览器的 python (3.6) 中的 selenium 编码中设置代理。

from selenium import webdriver

PROXY = "94.56.171.137"
PORT = 8080

base_url = "https://google.com"

desired_capability = webdriver.DesiredCapabilities.INTERNETEXPLORER
desired_capability['proxy'] = {
    "proxyType": "manual",
    "httpProxy": PROXY,
    "httpProxyPort": PORT,
    "ftpProxy": PROXY,
    "ftpProxyPort": PORT,
    "sslProxy": PROXY,
    "sslProxyPort": PORT,
    "class":"org.openqa.selenium.Proxy",
}

driver = webdriver.Ie(executable_path='C:\\tmp\\IEDriverServer',capabilities=desired_capability)
driver.get(base_url)

我收到以下错误消息 -

<p>The following error was encountered while trying to retrieve the URL: <a href="http://127.0.0.1:54684/session">http://127.0.0.1:54684/session</a></p>

我从下面获取了参考-

https://stackoverflow.com/questions/45949274/setting-proxy-in-selenium-in-python-for-firefox-geckodriver?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

它在FireFox浏览器中运行良好,但我无法在IE浏览器中运行。

【问题讨论】:

    标签: python selenium internet-explorer selenium-webdriver iedriverserver


    【解决方案1】:

    看来你已经很接近了。当您在 Windows 操作系统 上时,您需要添加 WebDriver Binary 的扩展名(即 .exe)。此外,将 IEDriverServer 的绝对路径放在单引号中(即 '')以及 文件分隔符 作为 单前斜杠(即\)前面是原始(即r)开关,如下所示:

    driver = webdriver.Ie(executable_path=r'C:\tmp\IEDriverServer.exe', capabilities=desired_capability)
    

    【讨论】:

      猜你喜欢
      • 2023-03-15
      • 2011-08-22
      • 2013-11-07
      • 2011-03-04
      • 2017-12-09
      • 2017-12-30
      • 1970-01-01
      • 1970-01-01
      • 2018-02-10
      相关资源
      最近更新 更多