【发布时间】:2023-01-30 20:53:43
【问题描述】:
我正在尝试在 selenium python 中使用代理,但是当我在显示我的 ip 的网页上测试代码时,代理不会更改我的 ip 地址。
这里有代码
import undetected_chromedriver as uc
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
option = Options()
driver = uc.Chrome(options = option)
PROXY = "139.162.214.146"
option.add_argument('--proxy-server=%s' % PROXY)
option.add_argument('--disable-extensions')
option.add_argument('--disable-notifications')
option.add_argument('--no-sandbox')
option.add_argument('--disable-dev-shm-usage')
option.add_argument('--disable-gpu')
option.add_argument('--mute-audio')
option.add_argument('--ignore-certificate-errors')
option.add_argument('--disable-logging')
driver.get("https://www.whatismyip.com/")
input ()
代码应该更改 mi ip 但这并没有发生,我试图更改代理但问题是一样的。
【问题讨论】:
-
在所有
add_argument语句之后移动这行代码driver = uc.Chrome(options = option)。你也需要提供port。
标签: python selenium-webdriver proxy selenium-chromedriver