How to use authenticated proxy in selenium chromedriver?

前端 未结 7 875
挽巷
挽巷 2020-12-14 08:10

After searching for many hours I am starting to think this is impossible.

I need to run Chrome through selenium using different authenticated (not public) proxy\'s f

7条回答
  •  眼角桃花
    2020-12-14 08:41

    This is the best solution I found and is the ONLY one that worked - all other answers on this question are outdated. It basically generates an auth extension for Chrome on the fly. Simply use the function as defined in the script as follows:

    driver = proxy_chrome(host, port, username, password)
    driver.get("http://www.icanhazip.com/")
    driver.get("https://www.reddit.com/")
    print('Terminated without issues.')
    

    Note that this doesn't work with the --headless option. However, on Linux, you can simply use the x virtual frame buffer to simulate that. It's as easy as this in python:

    import xvfbwrapper
    x = xvfbwrapper.Xvfb()
    x.start()
    

提交回复
热议问题