简体   繁体   English

Python请求未存储的Cookie

[英]Python Requests Cookies not stored

I am trying to login to a page using Python requests (2.10.0). 我正在尝试使用Python请求(2.10.0)登录到页面。

Code : 代码

payload = {
    'user_login': 'amitg.ind@gmail.com',
    'user_pass': 'xxx',
    'rememberme': '1'
}
with requests.session() as sess:
    resp = sess.post(URL_LOGIN, data=payload)
    print resp.cookies

This should have returned multiple cookies. 这应该返回了多个cookie。 When I see in Chrome developer tools, I see the following: 当我在Chrome开发人员工具中看到时,会看到以下内容:

Cookies张贴登录 在此处输入图片说明

However, when I print it on console, I see only the last cookie. 但是,在控制台上打印时,我只能看到最后一个cookie。 Rest all are lost. 其余的一切都丢失了。 The same login password works in browser. 相同的登录密码在浏览器中有效。 Due to this, subsequent request from same session fails. 因此,来自同一会话的后续请求失败。

RequestsCookieJar [Cookie wordpress_test_cookie=WP+Cookie+check for some.domain] . RequestsCookieJar [Cookie wordpress_test_cookie = WP + Cookie + check some.domain]

Why are the other cookies not preserved in session. 为什么其他cookie不在会话中保留。 All other subsequent requests doesn't recognize the login and I suspect its because of the missing cookies. 其他所有后续请求均无法识别该登录名,我怀疑是由于缺少Cookie所致。

Could anyone help please? 有人可以帮忙吗?

Thanks @Padraic - I was using the 'id' attribute but 'name' was to be used. 感谢@Padraic-我使用的是'id'属性,但要使用'name'。 Thanks for that. 感谢那。 wp-submit was not required. 不需要wp-submit。 Thanks again. 再次感谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM