【问题标题】:Selenium - Https issue with PhantomJS and Proxy Auth with FirefoxSelenium - PhantomJS 的 Https 问题和 Firefox 的代理身份验证
【发布时间】:2016-03-12 10:56:38
【问题描述】:

好的,所以我的目标是通过代理连接到 https 网站,该代理需要身份验证而无需任何人工交互。

解决方案 #1:Firefox

fp = webdriver.FirefoxProfile()
fp.set_preference("network.proxy.type", 1)
fp.set_preference("network.proxy.http", "IP")
fp.set_preference("network.proxy.http_port", PORT)
driver = webdriver.Firefox(firefox_profile=fp)
driver.get("http://www.google.com")

问题:一旦浏览器打开,它会打开用户名和密码的身份验证弹出窗口。

alert = driver.switch_to_alert()
alert.send_keys('balbla')

不起作用,根本没有反应。 将代理更改为也没有运气

http://username:password@ip

解决方案 #2:PhantomJs

使用 phantomjs 我设法在代码中进行身份验证:

service_args = [
    '--proxy=https://IP:PORT',
    '--proxy-type=http',
    '--proxy-auth=USERNAME:PASSWORD',
    ]
br = webdriver.PhantomJS(PATH,service_args=service_args)
br.get('https://www.google.com/')

问题:我无法浏览任何 https 网站,例如我正在尝试进入 https://www .gmail.com,我得到空白页面。 代理肯定在使用 https(手动加倍检查)。

添加

'--ssl-protocol=any'

效果不佳。

我在 Linux 环境下使用 selenium 和 python。寻找任何可以帮助我解决问题的解决方案。

谢谢。

【问题讨论】:

    标签: python selenium proxy automation phantomjs


    【解决方案1】:

    我想这有点晚了:) - 但基本上从代理中删除 https 并将代理类型设置为 https 即:

    service_args = [
        '--proxy=IP:PORT',
        '--proxy-type=https',
        '--proxy-auth=USERNAME:PASSWORD',
        ]
    

    【讨论】:

      猜你喜欢
      • 2019-01-01
      • 1970-01-01
      • 2019-11-06
      • 2011-08-08
      • 2012-08-24
      • 2019-01-05
      • 2021-10-07
      • 2022-08-19
      • 1970-01-01
      相关资源
      最近更新 更多