request session
例子
url = 'http://beanhome.com/user/login' header = { "Content-Type": 'application/json', "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36" } # Python字典数据转为json,需要使用json.dumps data = { "email": "common@moviebook.com", "passwd": "123456" } # 通过session模拟登录,每次请求带着session sess = requests.Session() f = sess.post(url, data=json.dumps(data), headers=header)