【Max】seleium中Chrome添加请求头代理cookie

1649644933   ·   发表于 24天前   ·   编程代码
一、添加header头
#【Max】团队招募–期待与你相遇#
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36")
driver = webdriver.Chrome(chrome_options=chrome_options)
#【Max】团队招募–期待与你相遇#
二、设置代理
#【Max】团队招募–期待与你相遇#
# 复制一份内置的配置文件
desired_capabilities = webdriver.DesiredCapabilities.INTERNETEXPLORER.copy()

# 改变配置文件的代理.
desired_capabilities['proxy'] = {
"httpProxy": 代理ip,
"ftpProxy": 代理ip,
"sslProxy": 代理ip,
"noProxy": None,
"proxyType": "MANUAL",
"class": "org.openqa.selenium.Proxy",
"autodetect": False
}

driver = webdriver.Chrome(desired_capabilities=desired_capabilities)
#【Max】团队招募–期待与你相遇#
三、添加单个cookie
#【Max】团队招募–期待与你相遇#
driver = webdriver.Chrome()
driver.delete_all_cookies()
driver.add_cookie(cookie)
四、添加多个cookie
driver = webdriver.Chrome()
driver.delete_all_cookies()
for cookie in cookies:
driver.add_cookie(cookie)

1 Reply   |  Until 23天前 | 4958 View

家家酒
发表于 24天前

自古一楼是楼主[滑稽]

评论列表

  • 加载数据中...

编写评论内容
LoginCan Publish Content