0
votes

am trying to use selenium to change my IP using a code I found but am getting an error: selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH `from selenium import webdriver

PROXY = "23.23.23.23:3128" # IP:PORT or HOST:PORT

chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--proxy-server=http://%s' % PROXY)

chrome = webdriver.Chrome(chrome_options=chrome_options) chrome.get("http://whatismyipaddress.com")`

2

2 Answers

1
votes

Here, I hope it helps :)

from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType

prox = Proxy()
prox.proxy_type = ProxyType.MANUAL
prox.http_proxy = "ip_addr:port"
prox.socks_proxy = "ip_addr:port"
prox.ssl_proxy = "ip_addr:port"

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

driver = webdriver.Chrome(desired_capabilities=capabilities)
0
votes

I solved this error by adding the executable path to the chrome variable

Here is my code :

from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=ipaddress:port')
driver = webdriver.Chrome(executable_path="your executable path",chrome_options=chrome_options)
 driver.get('https://www.myip.com/')