复习cookie登录豆瓣4月2号
原始URL:https://www.douban.com/
开发者工具查看XHR,填入错误的账号密码后查看增加的XHR文件获得URL:https://accounts.douban.com/j/mobile/login/basic
并且XHR文件是POST请求,滑下去看到Form Data,里面就是刚才填入的账号密码了,那就可以cookie登录了!
import requests url='https://accounts.douban.com/j/mobile/login/basic' headers={ 'Host':'accounts.douban.com', 'Origin':'https://accounts.douban.com', 'Referer':'https://accounts.douban.com/passport/login_popup?login_source=anony', 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36', 'X-Requested-With':'XMLHttpRequest' } cookie={ 'll':"118286", 'bid':'K8fEx0ZCopc', '__utma':'30149280.1684287518.1554213169.1554213169.1554213169.1', ' __utmc':'30149280', '__utmz':'30149280.1554213169.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)', '__utmt':'1', 'last_login_way':'account', 'ap_v':'0,6.0', 'push_noty_num':'0', 'push_doumail_num':'0', '__utmv':'30149280.19200', '__utmb':'30149280.10.10.1554213169', 'login_start_time':'1554213492137', } params={ 'ck':'', 'name':'账号', 'password':'密码', 'remember':'false', 'ticket':'', } response=requests.post(url,data=params,headers=headers,cookies=cookie) print(response.text)