selenium设置chrome代理

selenium设置chrome代理,第1张

selenium设置chrome代理
from selenium import webdriver

# 方法1
options = webdriver.ChromeOptions()
ip = '190.2.151.210:40071' 
options.add_argument(f"--proxy-server=http://{ip}")
driver = webdriver.Chrome(executable_path="./chromedriver.exe",chrome_options=options)



# 2
options = webdriver.ChromeOptions()
ip = '190.2.151.210:40071' 
desired_capabilities = webdriver.DesiredCapabilities.CHROME.copy()
desired_capabilities['proxy'] = {
        "httpProxy": f'{ip}',
        "noProxy": None,
        "proxyType": "MANUAL",
        "class": "org.openqa.selenium.Proxy",
        "autodetect": False
}
driver = webdriver.Chrome(executable_path="./chromedriver.exe",chrome_options=options, desired_capabilities=desired_capabilities)

了解更多分析及数据抓取可查看:
http://cloud.yisurvey.com:9081/html/d8acf20b-342f-4806-8dcc-5e6a8d00881d.html?ly=csdn
特别说明:本文旨在技术交流,请勿将涉及的技术用于非法用途,否则一切后果自负。如果您觉得我们侵犯了您的合法权益,请联系我们予以处理。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5670282.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存