python csrf token_python爬虫如何获取X-CSRF-Token

headers3 = {

"Accept": "application/json, text/javascript, */*; q=0.01",

"Accept-Encoding": "gzip, deflate",

"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",

"Connection": "keep-alive",

"Host": "www.wanplus.com",

"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0",

"Referer": "http://www.wanplus.com/schedule/38188.html",

"X-CSRF-Token": '825951840',

"X-Requested-With": 'XMLHttpRequest',

}

cookies = {

"gameType": "2",

"isShown": "1",

"wanplus_csrf": '_csrf_tk_809174624',

"wanplus_sid": '6b239b6267a66dd0d2c475f399c5c20a',

"wanplus_storage": 'lf4m67eka3o',

"wanplus_token": 'cb7edf09d3679c9f66d0575b8b667fa6',

}

url = 'http://www.wanplus.com/ajax/matchdetail/45569'

r = requests.get(url, headers=headers, cookies=cookies)

这段代码可以正确获取比赛信息,不过headers中的"X-CSRF-Token"和cookies的"wanplus_csrf"好像是随机的,请问应该如何获取这两个参数?

你可能感兴趣的:(python,csrf,token)