1、Cookies里面的FP_LASTTIME
和FP_UID
不知道如何获取
2、payload里面的_BSK
不知道如何获取。(在点击发表按钮之后会获取一段1843行的JS代码,感觉是用来加密什么然后得到的这个参数。)
是不是应该检查发表按钮的元素,看看这个按钮上绑定了哪些动作,然后对这些JS文件逐一分析?希望各界大牛不吝赐教,谢谢!
百度贴吧回贴代码(Python版本):
import requests
headers = {
'Host': 'tieba.baidu.com',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding': 'gzip, deflate, br',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With': 'XMLHttpRequest',
'Referer': 'https://tieba.baidu.com/p/5113276225',
'Content-Length': '1878',
'Connection': 'keep-alive'
}
cookies = {
'fixed_bar': '1', # 固定的,万年不变。
'TIEBAUID': '14d764bc1eae8f5834623981', # 登录获取
'TIEBA_USERTYPE': '5f4d5be13962828df0bb90e1', # 登录获取
'BAIDUID': 'F55EFC378015FB41FE66B2A5E4C7351E:FG=1', # 登录获取
'FP_LASTTIME': '1498723563061', # 目测像登录时间?或者是最后活跃时间?
'FP_UID': '9b899b3e7d0d51a6963d932f8046dc1a', # 登录时也有这个参数,不知道如何获取。
'BDUSS': 'FiR1pSLWY1eVV0NU1lNnd-YzVaY0FWME16NWRJczhJZWlaNk9Sfmp5Yn5RWHhaSVFBQUFBJCQAAAAAAAAAAAEAAAD5u622tsjI~besAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP-0VFn~tFRZUX', # 登录获取
'STOKEN': '2ce30a036d70b52438f54b4ad8b2261df7a68a2980d755f0ea5772f859378321', # 登录获取
'3064839161_FRSVideoUploadTip': '1', # 前面的数字不知道如何获取
'wise_device': '0' # 固定的,万年不变。
}
payload = {
'ie': 'utf-8',
'kw': '李彦宏', # 贴吧名
'fid': '42', # 贴吧fid
'tid': '5113276225', # 贴号
'vcode_md5': '', # 验证码的MD5
'floor_num': '3', # 回复后的所在楼层
'rich_text': '1',
'tbs': '5421d6a3b47f80071498725341', # 在贴子源码中获取
'content': '这里是回贴内容',
'basilisk': '1',
'files': '[]',
'mouse_pwd': '108,110,106,116,106,106,107,106,81,105,116,104,116,105,116,104,116,105,116,104,116,105,116,104,116,105,116,104,81,109,96,111,106,108,81,105,110,96,104,116,105,104,109,104,14987253481880',
'mouse_pwd_t': '1498725348188', # 时间戳
'mouse_pwd_isclick': '0',
'__type__': 'reply',
'_BSK': 'JVwVUWcLBBpxTAtoU3lCAFxLZyBpB08XWCwLVSAZZCNiEmpPRzsxGFkRNGZGFwodO106GFwjCWVkXlBTcAEICSZEEWVBOARFD0tnMmsHTxcMfVYRdQB3YX0SMVwRc2QbFF8uMkgPXlhrEn1SCz5bMzcRD0MxXndfNxxdOEllVktKR2V3AUsUQ1c7AgYmWiI1DE1yQxEodV9PE2xhXB0GSy0ZfQ5cJVY0LhsCCiNYQU9nWREtUG5MEgwSKzQuTBpZHj8GSCFaK3h4ECtPE2lkJhtSKT4SSAoKJkw6aQNyFGUyT0NZZ0tMBgY7EXNDP0QSUEd0YWIVWRVQfEUcZQd2YWYAZV4CZWYcQRFndwJMRhosBH1ZT3ICZTwfEgopWFdAGhR/KVEmERJGRSlleB9VQ0w4AgpnQndyaxIeOn8FZlFXRGl1Xg8aRSpEMEcbfEszMQ5NBSpSUVhpF18qE2AZQA8JaTY2QAdDEi4ISCNcND19QCIAXjkwUQVBNDkQAVkBJl8SWxoxVAM3Hw0MIh1URDYBfjoSPxdXD0smNipRAEVbCBFDK0E1fCNVPApSOiE4A1YzIxcBTQw9ezpYGzNMLjEQTQQgRWdEKAVGKwQoJUQTCyB7N0QBVFYAAkIsVGo9PkY1O1xlKRIDVh8uSF9PGiBSOmARfEoiLRcbBgdIBgdnBQJ9W25TByhCd2UuRwYSDH9CFQQQdGJkBGJeV38lThcHajFcHRpeeBxmDEliDXRqT0RRdxQTb2dZESpQbkwSJwg/PjZJFBgLY1cGbXgnMzheJABAIX9dPF0pMggNZwgqCBBnXggYdm5QUFF+EVZdf0AHcVFlVncPBC44dRdFBg59VhZ0FQA5I1U2AEtmcUlbA397RkMYS3MIK0YLNRRlLk1DWWVXRUc2EB99AH5UCkpefWV2BwUFHHdFayRWDz4lVTxNH2szT1cJfxkxYWZLZQoxB1xqGHVuT1ZTcAAVVg==', # 不知道如何获取
}
http = requests.post('https://tieba.baidu.com/f/commit/post/add', headers=headers, cookies=cookies, data=payload)
print(http.text)