不加cookie的代码
from time import sleep
from selenium import webdriver
url = 'https://xxxxxxxxxxxxx'
browser = webdriver.Firefox()
browser.get(url)
sleep(2)
加cookie的代码
1.注意cookie的格式
2.注意上下有两次get请求
from time import sleep
from selenium import webdriver
url = 'https://xxxxxxxxxxxxxx'
cookie = {
"name": "uid",
"value": "xxxxxxxx04dYnN-Ro5zrLl_Br5TOQje1K096Xlnj-yC145FCp76BXUh3maHa",
"domain": ".xxxxxx.com",
"hostOnly": False,
"path": "/",
"secure": False,
"httpOnly": True,
}
browser = webdriver.Firefox()
browser.get(url)
sleep(2)
browser.add_cookie(cookie_dict=cookie)
browser.get(url)
sleep(2)