1.登录豆瓣
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
def login_douban():
'''功能:自动登录豆瓣网站'''
global browser
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_driver = 'C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe'
browser = webdriver.Chrome(chrome_options=chrome_options, executable_path = chrome_driver)
login_url = 'https://accounts.douban.com/passport/login?source=movie'
browser.get(login_url)
browser.find_element_by_class_name('account-tab-account').click()
username = browser.find_element_by_id('username')
username.send_keys('xxxxxx')
password = browser.find_element_by_id('password')
password.send_keys('xxxxxx')
browser.find_element_by_class_name('btn-account').click()