from seleniumimport webdriver
from selenium.webdriverimport ActionChains
driver = webdriver.Chrome()
#获取到cookies
def get_cookies():
driver.get('https://www.163.com/')
Lg_bt = driver.find_element_by_id('js_N_nav_login_title')
ActionChains(driver).move_to_element(Lg_bt).perform()
input('输入完密码请输入q')
cookies = driver.get_cookies()
return cookies
cookies = get_cookies()
driver = webdriver.Chrome()
driver.get('https://www.163.com/')
driver.delete_all_cookies()
for cookiein cookies: #遍历cookies,删掉expiry过期时间,然后加载到cookie()传给driver
if 'expiry' in cookie.keys():
del cookie['expiry']
driver.add_cookie(cookie)
driver.refresh()