I added a proxy to Selenium and now the page won't open [Python]

Question:

My bot successfully worked on my local network.
But by adding proxies as if lost connection to the network…

Here’s my code:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.chrome.options import Options
from time import sleep

# SMM Setup
VIDEO = 'https://www.youtube.com/watch?v=TjiUC8jeF1o'
VIEWS = 20

# PROBLEM SETUP
PROXIES = [
    '0.0.0.0:0000',
    '0.0.0.0:0000',
    '0.0.0.0:0000',
    '0.0.0.0:0000',
    '0.0.0.0:0000',
    '0.0.0.0:0000',
    '0.0.0.0:0000',
    '0.0.0.0:0000',
    '0.0.0.0:0000',
    '0.0.0.0:0000'
]
YOUTUBE_ACCEPT_COOKIES_A = '/html/body/ytd-app/ytd-consent-bump-v2-lightbox/tp-yt-paper-dialog/div[4]/div[2]/div[6]/div[1]/ytd-button-renderer[2]/a/tp-yt-paper-button'
YOUTUBE_ACCEPT_COOKIES_B = '/html/body/ytd-app/ytd-consent-bump-v2-lightbox/tp-yt-paper-dialog/div[4]/div[2]/div[6]/div[1]/ytd-button-renderer[2]/yt-button-shape/button'

# start - 153

# Init
global driver

# Create Views
for x in range(len(PROXIES)):
    options = Options()
    options.add_argument('--proxy-server=%s' % PROXIES[x])
    driver = webdriver.Chrome(executable_path='C:/Users/sasha/OneDrive/Desktop/CHROME_DRIVER/chromedriver.exe', chrome_options = options)
    driver.get(VIDEO)
    for y in range(VIEWS / PROXIES):
        driver.refresh()
        try:
            WebDriverWait(driver, 1).until(EC.element_to_be_clickable((By.XPATH, YOUTUBE_ACCEPT_COOKIES_A))).click()
        except TimeoutException:
            try:
                WebDriverWait(driver, 1).until(EC.element_to_be_clickable((By.XPATH, YOUTUBE_ACCEPT_COOKIES_B))).click()
            except:
                print('Any Cookie Accepts Not Found')
        sleep(2)
    driver.quit()

# Close All Tabs
driver.quit()

I tried to remove chrome_options = options. It worked.
But I can’t use my local network for some reason.

Asked By: SonicallGameX

||

Answers:

Try to change port

Example: 4444 to 12345 / 55555

Answered By: SonicallGameX