Answer the question
In order to leave comments, you need to log in
Python, urllib, how to get data from debug?
I'm trying to login to the site to get cookies, the code is like this:
def login(login, password) :
data = urllib.urlencode({'shop_user[login]': login, 'shop_user[pass]': password, 'shop_user[mem]': 'on', 'auth': '%E2%EE%E9%F2%E8+%ED%E0+%F1%E0%E9%F2'})
headers = {"User-Agent" : "Mozilla/5.0", "Accept" : "application/x-www-form-urlencoded"}
request = urllib2.Request(url, data, headers)
httpHandler = urllib2.HTTPHandler()
httpHandler.set_http_debuglevel(1)
opener = urllib2.build_opener(httpHandler)
urlHandle = opener.open(request)
Answer the question
In order to leave comments, you need to log in
request = urllib2.Request(url, data, headers)
response = urllib2.urlopen(request)
print response.headers['Set-Cookie']
wrote from memory. Check. :)
so in the set-cookie header all cookies are in the form cookie1=value1&cookie2=value2
I recommend using PyCharm - there is a tracer of all variables
Then via cookielib www.codercaste.com/2009/11/28/how-to-use-the-urllib-python-library-to-fetch-url-data-and-more/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question