-sharpcoding=utf-8
from selenium import webdriver
import time
req_url = "http://www.baidu.com/"
browser = webdriver.Chrome()
browser.get(req_url)
browser.delete_all_cookies()
cookie=[] -sharp browser.get_cookies()cookie
for t in cookie:
browser.add_cookie(t)
browser.refresh()
because there are a number of Baidu accounts and accounts whose cookie used to use the program to simulate entering the account password to log in, but recently, these accounts all need mobile phone verification to continue to log in, but it is found that it is not necessary to log in with cookie, but it is not successful to log in with python+selenium.
the above code is for me to use my own account password that does not require verification. Previously, I successfully used selenium to enter the account password to log in to Baidu. Then browser.get_cookies () out of the cookie through add_cookie to request Baidu to show that the login is successful, but after clicking on the personal Center, or not logged in status, ask for advice to see what the problem is in the end!