示例:自动登录抽屉新热榜

response.cookies 是对象  再get_dict()  返回的是字典

访问上一次登录状态要有cookie

get和post都有cookies

import requests
post_dict = {
    "phone": '8615131255089',
    'password': 'woshiniba',
    'oneMonth': 1
}
response = requests.post(
    url="http://dig.chouti.com/login",
    data=post_dict
)
print(response.text)
cookie_dict = response.cookies.get_dict()
print(cookie_dict)

response = requests.get(
    url='http://dig.chouti.com/profile',
    cookies=cookie_dict
)
print(response.text)
s2.py

猜你喜欢

转载自www.cnblogs.com/jintian/p/11391995.html