模拟登陆基本原理,理解Post、Cookies和Session
import requests
#通过cookies登录
post_url='http://pythonscraping.com/pages/cookies/welcome.php'
userdata={"username":"zhangsan","password":"password"}
post_res=requests.post(post_url,userdata)
print(post_res.cookies.get_dict())
# print(post_res.text)
#通过session登录
mysession=requests.Session()
post_url='http://pythonscraping.com/pages/cookies/welcome.php'
userdata={"username":"lisi","password":"password"}
r=mysession.post(post_url,userdata)
print(r.cookies.get_dict())