【问题标题】:How to set HTTPS proxy in PhantomJS?如何在 PhantomJS 中设置 HTTPS 代理?
【发布时间】:2017-09-01 02:34:27
【问题描述】:

设置 PhantomJS HTTPS 代理有一个问题。使用以下代码。请帮帮我。

service_args = [
    '--proxy='+ip[1],
    '--proxy-type=http',
]
driver = webdriver.PhantomJS(executable_path= os.getcwd()+'/driver/phantomjs.exe',service_args=service_args)

Python 请求使用 HTTPS 代理是可以的,但是我设置的 PhantomJS HTTPS 代理无法访问。 Python请求使用HTTPS代理,使用如下代码:

proxies = { "https":ip[1] }
stringContent = requests.get("http:xx.com",headers = headers,proxies=proxies)

【问题讨论】:

    标签: python-3.x selenium phantomjs


    【解决方案1】:

    PhantomJS 不支持 https 代理。所以最好是使用 http 代理或 socks 代理

    --proxy-type= 指定代理类型,'http'(默认)、'none'(完全禁用)或'socks5'

    如果出于某种原因,您仍然希望事情正常工作,那么您需要像 SQUID 或其他可以侦听 http 代理并将其转发到 https 代理的代理服务器。

    在这种情况下,以下链接可能会有所帮助

    https://www.rootusers.com/configure-squid-proxy-to-forward-to-a-parent-proxy/

    Squid: forward to another proxy (with authentication details for the parent proxy)

    【讨论】:

      猜你喜欢
      • 2015-04-18
      • 1970-01-01
      • 2013-01-19
      • 1970-01-01
      • 2017-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多