How to get cookie from an urllib.request
?
import urllib.request
import urllib.parse
data = urllib.parse.urlencode({
'user': 'user',
'pass': 'pass'
})
data = data.encode('utf-8')
request = urllib.request.urlopen('http://example.com', data)
print(request.info())
request.info()
returns cookies but not in very usable way.
request
but that's aresponse
object. The question is vague and could be solved in many different ways, but we don't know what are you trying to achieve (thus the "what is a usuable way?") – Presence