server responses sessionid on first request.How to use that sessionid on second request?
You are already using requests.session()
; it handles cookies for you, provided you keep using the session for all your requests:
url = "some url of login page"
payload = {'username': 'p05989', 'password': '123456'}
with requests.session() as s:
# fetch the login page
s.get(url)
sessionid = s.cookies.get('SESSIONID')
# post to the login form
r = s.post(url1, data=payload)
print(r.text)
You probably do first need to use GET
to get the session id set before posting to the login form.
The SESSIONID
cookie is handled transparently for you.