0

Trying to set a proxy using the following code:

from selenium.webdriver.common.proxy import Proxy, ProxyType
prox = Proxy()
prox.proxy_type = ProxyType.MANUAL
prox.http_proxy = "1.10.186.114:46863"
prox.socks_proxy = "1.10.186.114:46863"
prox.ssl_proxy = "1.10.186.114:46863"

capabilities = webdriver.DesiredCapabilities.CHROME
prox.add_to_capabilities(capabilities)

driver = webdriver.Chrome(desired_capabilities=capabilities)

I keep getting an exception thrown at the line driver = webdriver.Chrome(desired_capabilities=capabilities). The exception mentions Message: invalid argument: cannot parse capability: proxy from invalid argument: Specifying 'socksProxy' requires an integer for 'socksVersion'

The proxy I am trying to use was just a free one found online, does anyone have any ideas how to solve this?

Thanks in advance.

mya205
  • 93
  • 1
  • 11
  • Does this answer your question? [Python3, can't set socks proxy with chromedriver (socks.py type integer error)](https://stackoverflow.com/questions/50662935/python3-cant-set-socks-proxy-with-chromedriver-socks-py-type-integer-error) – Thomas Weller Dec 23 '20 at 17:11
  • I used the code there and went on "https://whatismyipaddress.com/" but my IP is still being reported which means the proxy didn't get set. Any ideas? – mya205 Dec 23 '20 at 17:41

1 Answers1

0

Update solved:

PROXY ="INPUT YOUR PROXY HERE, FOLLOWED BY PORT NUMBER" #KEY HERE IS THAT YOU ENSURE TO SPECIFY 'http=' or 'socks4/socks5=' DEPENDING ON YOUR PROXY
print(PROXY)
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)

chrome = webdriver.Chrome(options=chrome_options)
chrome.get("http://whatismyipaddress.com")
time.sleep(3)
mya205
  • 93
  • 1
  • 11