如何为 selenium webdriver 设置 socks5 代理?Python [英] How can I set socks5 proxy for selenium webdriver? Python

查看:131
本文介绍了如何为 selenium webdriver 设置 socks5 代理?Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的无法在 selenium for python 中为我的 chrome webdriver 设置 socks5 代理(http 也是...).我尝试了很多不同的方法……但我认为我做了一些坏事.

I really can’t to set socks5 proxy(http too...) for my chrome webdriver in selenium for python. I tried many different ways... But I think I do something bad.

示例 1:

self.options.add_argument('--proxy-server=http://'+proxy)

示例 2:

webdriver.DesiredCapabilities.CHROME['proxy'] = {
        "socksProxy": proxy,
        "ftpProxy": proxy,
        "sslProxy": proxy,
        "noProxy": None,
        "proxyType": "MANUAL",
        "class": "org.openqa.selenium.Proxy",
        "autodetect": False
    }

请完整描述在Selenium上为Python和Chrome webdriver设置socks5代理的工作示例,以及代理字符串格式的示例(也许我在这里做错了......).

Please describe fully the working example of setting up socks5 proxy on Selenium for Python and Chrome webdriver, with an example of proxy string formats (maybe i am doing something mistakes here ...).

PS 我遇到的两个问题:

PS Two problems which I get:

  1. 只保留旧 IP 地址.
  2. chrome 网络驱动程序中没有互联网连接.

推荐答案

Chrome 不允许使用 auth 代理. 我不是舒尔,但在阅读了这么多信息后我认为是这样.... 只有一种方法对我有用 - 无需通过登录名和密码进行身份验证即可使用代理 socks5.

Chrome do not allow proxy with auth. I am not shure but after read so many informations I think so.... Only one way is working for me - to use proxy socks5 without auth by login and password.

 options = webdriver.ChromeOptions()
 proxy = '12.12.421.125:1949'   
 options.add_argument('--proxy-server=socks5://' + proxy)
 driver = webdriver.Chrome(options=options)

这篇关于如何为 selenium webdriver 设置 socks5 代理?Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆