python请求并获取cooki

2024-10-04 05:21:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我有此要求:

Host: subdomain.test.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json
X-Requested-With: XMLHttpRequest
Content-Length: 66
Connection: close
Referer: https://subdomain.test.com/login
Cookie: _gcl_au=1.1.1234502517.1571027917; _ga=GA1.2.763005402.1571027922; _fbp=fb.1.1571027923235.548273364; _hjid=9ae69402-9cd0-4e93-8e11-e6fdd78de9c3; PHPSESSID=12345c63db530475e3480d3c4e12345; _gid=GA1.2.1079574959.1571624463; _gat_UA-4593965-2=1

email=this@email.com&shownPassword=test123QWE&password=test123QWE

这是我的代码:

import requests
from requests import session

payload = {
    'email' : 'this@email.com',
    'shownPassword' : 'test123QWE',
    'password' : 'test123QWE'
}


with session() as c:
    c.post('https://subdomain.test.com/login', data=payload)
    response = c.get('https://subdomain.test.com/login')

    print(response.cookies)

以下是回应:

<RequestsCookieJar[]>

所以我的问题是,我怎样才能得到饼干

谢谢


Tags: subdomainhttpstestcomjsonapplicationemaillogin