python 模拟登录淘宝保存choice
源码
from selenium import webdriver
from time import sleep
from selenium.webdriver import ActionChains
chrome = webdriver.Chrome()
chrome.get('https://login.taobao.com/member/login.jhtml?')
sleep(2)
username_input = chrome.find_element_by_id("fm-login-id")
password_input = chrome.find_element_by_id("fm-login-password")
username_input.send_keys('用户名')
password_input.send_keys('密码')
sleep(1)
slider = chrome.find_element_by_xpath('/html/body/div/div[2]/div[3]/div/div[1]/div/div[2]/div/form/div[3]/div/div/div[1]/span')
action = ActionChains(chrome)
action.click_and_hold(slider)
try:
action.move_by_offset(258,0).perform()
except:
pass
action.release()
login_button = chrome.find_element_by_xpath("/html/body/div/div[2]/div[3]/div/div[1]/div/div[2]/div/form/div[4]/button")
login_button.click()
sleep(2)
html = chrome.page_source
choice = chrome.get_cookies()
print(choice)
chrome.close()