'How do I automate this chrome tab with a proxy instead of using my own IP everytime

Like if I had a list of proxies how can I incorporate it to open the tab with it.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Chrome()
driver.get('https://www.youtube.com/watch?v=QggJzZdIYPI&ab_channel=CandRfun')

#using this link as an example.



Solution 1:[1]

The just replace the ip of your proxy and port with desired ip and desired port in 2nd line.

from selenium import webdriver
    PROXY = "The desired IP:Desired port"
    chrome_options = WebDriver.ChromeOptions()
    chrome_options.add_argument('--proxy-server=%s' % PROXY)
    chrome = webdriver.Chrome(chrome_options=chrome_options)
    chrome.get("https://www.youtube.com/watch?v=QggJzZdIYPI&ab_channel=CandRfun")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sonali Das