0

I am trying to make a proxy in python using selenium i have a list of free proxies from https://free-proxy-list.net/ but the ip i get is always the same, there is something wrong with this setup?

PROXY = proxy_list[11]
options = Options()
options.headless = False

webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
    "httpProxy":PROXY,
    "ftpProxy":PROXY,
    "sslProxy":PROXY,
    "noProxy":None,
    "proxyType":"MANUAL",
    "class":"org.openqa.selenium.Proxy",
    "autodetect":False
}
driver = webdriver.Firefox(options=options, executable_path=r'geckodriver.exe')
# Set the interceptor on the driver
driver.request_interceptor = interceptor 
driver.get(url)
time.sleep(5)
driver.quit()

EDIT: i am running according to the response the following code:

url = 'https://www.whatismyip.com/es/'
PROXY = proxy_list[6]
options = Options()
options.headless = False

firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['proxy'] = {
    'proxyType': "MANUAL",
    'httpProxy': PROXY,
    'ftpProxy': PROXY,
    'sslProxy': PROXY
}
driver = webdriver.Firefox(options=options, executable_path=r'geckodriver.exe', capabilities = firefox_capabilities)
# Set the interceptor on the driver
driver.request_interceptor = interceptor 
driver.get(url)
time.sleep(50)
driver.quit()

But the ip in the webpage is always the same, dunno if missunderstood the use of the proxy or i am doing something wrong

1 Answer 1

3

If you use Firefox browser,

...
# set proxy
firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['proxy'] = {
    'proxyType': "MANUAL",
    'httpProxy': PROXY,
    'ftpProxy': PROXY,
    'sslProxy': PROXY
}
driver = webdriver.Firefox(options=options, executable_path=r'geckodriver.exe', capabilities = firefox_capabilities)

If you use Chrome,

...
chrome_options = Options()
chrome_options.add_argument('--proxy-server=' + PROXY)
chrome_options.add_argument("--headless") 
driver = webdriver.Chrome(executable_path = 'chromedriver.exe', options=chrome_options)
Sign up to request clarification or add additional context in comments.

1 Comment

what is the code for chrome?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.