python - HTTPCookieProcessor not serving cookies -
i trying access website requires cookies. using urllib2 , cookielib able response site. html printout informs me not getting access line:
<h2>cookies disabled</h2> <p> class="share-prompt"><strong>cookies must enabled.</strong></p>
i cannot understand going wrong. code below:
import urllib2, cookielib cookiejar = cookielib.cookiejar() opener = urllib2.build_opener(urllib2.proxyhandler({'http':"http://216.208.156.69:3128"}),urllib2.httpcookieprocessor(cookiejar)) request = urllib2.request("[website]") response = opener.open(request) print response.read()
can see have gone wrong?
cheers,
the code looks good. example output this
import urllib, urllib2, cookielib cookiejar = cookielib.cookiejar() opener = urllib2.build_opener(urllib2.httpcookieprocessor(cookiejar)) params = urllib.urlencode({'cookie_name': 'cookie_value'}) request = urllib2.request('http://httpbin.org/cookies/set?' + params) opener.open(request) request = urllib2.request('http://httpbin.org/cookies') response = opener.open(request) print response.read()
is
{ "cookies": { "cookie_name": "cookie_value" } }
without showing url use not can done.
Comments
Post a Comment