2

I'd like to open a Chrome instance on Python though selenium using a proxy to hide my real IP and stop getting blocked when I scrape certain websites.

I have been going thought several similar posts like this and this but with no success.

I am using the following code:

from selenium import webdriver

PROXY = "165.22.62.179:8118" # IP:PORT or HOST:PORT
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)
chrome = webdriver.Chrome(executable_path = path_to_chromedriver, options=chrome_options)
chrome.get(target_website)

The instance open correctly but when I run the command chrome.get(target_website) I get no answer:

enter image description here

If I open the instance without proxy it works fine. I am getting the proxies from this website. I want to create a function that takes as input a proxy IP and returns a running Chrome instance that uses that IP.

Can you please me help to fix my code? Thanks for your help!

AndrewTG
  • 43
  • 4

0 Answers0