无法使用以下参数在网站中登录我的帐户:
token=...#by xpath
postdata={'token':token, 'arg1':'', 'arg2':'', 'name[user]': user, 'name[password]':password, 'arg3': 'Sign in'}
postresp=requests.post(url='http://example.com', data=postdata)
.
.
.
我应该将名称[user]更改为name%5Buser%5D
吗?
我应该将name [password]更改为name%5Bpassword%5D
吗?
我应该将登录更改为Sign+in
吗?
arg1和arg2为空白。我应该删除它们吗?
如果没有,我该如何更改它们?因为我无法登录我的帐户...
请求库已经对您的字典进行了编码。但是,如果您想自己做,则应使用字符串。对于字典,请尝试以下操作:
postdata={
'token':token,
'arg1':'',
'arg2':'',
'name[user]': user, # I think this should be : instead of ,
'name[password]':password,
'arg3': 'Sign in'}
headers={
'Content-Type': 'application/x-www-form-urlencoded'
# With this header you tell the server you're sending form params
}
postresp=requests.post(url='http://example.com', headers=headers, data=postdata)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句