selenium模拟登录京东

from selenium import webdriver
import time
from lxml import etree
import requests
# import ssl
#
# ssl._create_unverified_context()
# selenium抓到cookie,再用request
# selenium解决验证码模拟登录不需要解决加密问题
# request,urllib只能处理非加密的post,速度快

url = 'https://passport.jd.com/uc/login?ltype=logout'
# 跳转到账户登录
driver = webdriver.Firefox()
driver.get(url)
driver.find_element_by_link_text('账户登录').click()

# 用户名跟密码的设置并点击提交
user = driver.find_element_by_id('loginname')
user.clear()
pwd = driver.find_element_by_id('nloginpwd')
pwd.clear()
submit = driver.find_element_by_id('loginsubmit')
time.sleep(2)
user.send_keys('13580416180')
pwd.send_keys('JiangWei112')
time.sleep(1)
submit.click()
time.sleep(5)
 

你可能感兴趣的:(selenium模拟登录京东)