[英]Python Selenium Proxy doesn't change IP address
I'm trying to change my IP address in order to bypass crawl social data using this code:我正在尝试更改我的 IP 地址,以便使用以下代码绕过抓取社交数据:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
if __name__ == '__main__':
chromedriver_path = '/usr/local/bin/chromedriver'
window_size = "1920,1080"
chrome_options = Options()
chrome_options.add_argument("--window-size=%s" % window_size)
random_proxy = '124.240.187.80:82'
webdriver.DesiredCapabilities.CHROME['proxy'] = {
"httpProxy": random_proxy,
"ftpProxy": random_proxy,
"sslProxy": random_proxy,
"proxyType": "MANUAL"
}
webdriver.DesiredCapabilities.CHROME['acceptSslCerts'] = True
chromedriver = webdriver.Chrome(
executable_path=chromedriver_path,
options=chrome_options
)
chromedriver.get('https://whatismyip.com')
But it doesn't works.但它不起作用。 My IP address remain the same.
我的 IP 地址保持不变。 Any sugesstion?
有什么建议吗? Thanks a ton.
万分感谢。
Try using ChromeOptions
instead of Chrome capabilities尝试使用
ChromeOptions
而不是 Chrome 功能
chrome_options = Options()
chrome_options.add_argument(f'--proxy-server={random_proxy}')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.