I have been trying to rotate some IPs with this piece of code. It didn't work. It still gave me my own IP. Could anyone help me check if there is anything wrong with it?
This is my code:
import random
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
ips = ["185.199.228.220:7300", "185.199.231.45:8382"]
def rand_proxy():
proxy = random.choice(ips)
return proxy
def myip_now():
chrome_options = webdriver.ChromeOptions()
proxy = rand_proxy()
chrome_options.add_argument(f'--proxy-server = {proxy}')
driver = webdriver.Chrome(options = chrome_options)
driver.get("https://myexternalip.com/raw")
print(proxy)
time.sleep(10)
driver.quit()
myip_now()
What I expected was that on https://myexternalip.com/raw controlled by my bot, I should see either 185.199.228.220:7300
or 185.199.231.45:8382
.