我查看了stackoverflow上的许多其他回复,并观看了一些youtube上的长视频,还没有找到可以解决我问题的信息。我曾在其他情况下使用post登录和刮取,只是在有请求令牌时没有。也许有人可以看看?我将在图片中包含post参数。应该注意的是,每次我登录时,_RequestVerificationToken都会更改
import requests
payload = {
'Email': 'dfo.msdi-idsm.mpo@dfo-mpo.gc.ca',
'Password': 'notrealpassword',
'__RequestVerificationToken': 'RuOal6rKBCWdjNy_15nTS9duFSkM586yGD3LxlWrlGzBB3Noaha9hAm3-tMq9HPvvMstDL8BZ8PvQLPutsreSeGwQOzK1MMwl76Q2c7n1zo1',
}
URL = 'http://gisd.dfo-mpo.gc.ca/DFO_WebServiceManager/Account/Login'
Pacific = 'https://gisd.dfo-mpo.gc.ca/DFO_WebServiceManager/FGP?SearchString=Pacific'
with requests.session() as c:
c.post(URL, data=payload)
r = c.get(Pacific)
print r.content
该令牌看起来像CSRF令牌。您应该将包含
__RequestVerificaionToken
的cookie添加到请求中,并查看它是否有效相关问题 更多 >
编程相关推荐