码迷,mamicode.com
首页 > 编程语言 > 详细

【Rollo的Python之路】Python 爬虫系统学习 (六) Selenium 模拟登录

时间:2019-06-28 23:14:19      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:you   cookies   int   form   sel   mail   span   模拟登录   登录   

selenium 模拟登录:

 

from selenium import webdriver
import time

driver = webdriver.Chrome()
driver.get("https://www.douban.com/")
driver.find_element_by_id("form_email").send_keys("your account")
driver.find_element_by_id("form_password").send_keys("password")

time.sleep(5)

driver.find_element_by_class_name("bn-submit").click()


cookies = {i["name"]:i["value"] for i in driver.get_cookies()}

print(cookies)

time.sleep(3)
driver.close()
driver.quit()

 

【Rollo的Python之路】Python 爬虫系统学习 (六) Selenium 模拟登录

标签:you   cookies   int   form   sel   mail   span   模拟登录   登录   

原文地址:https://www.cnblogs.com/rollost/p/11104932.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!