0

I found something similar to something I want to do using urllib2 here: How to use Python to login to a webpage and retrieve cookies for later usage?

Their solution was :

import urllib, urllib2, cookielib

username = 'myuser'
password = 'mypassword'

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'username' : username, 'j_password' : password})
opener.open('http://www.example.com/login.php', login_data)
resp = opener.open('http://www.example.com/hiddenpage.php')
print resp.read()

I want something like this using pycurl if possible. Any assistance would be appreciated.

Community
  • 1
  • 1
jyim89
  • 245
  • 3
  • 12

1 Answers1

1

This looks a lot like a dupe of Logging in and using cookies in pycurl. You give pycurl a path to a file to write cookies to with

c.setopt(pycurl.COOKIEJAR, 'cookie.txt')

and a path to read them from (probably the same) with

c.setopt(pycurl.COOKIEFILE, 'cookie.txt')
Community
  • 1
  • 1
spam_eggs
  • 1,058
  • 6
  • 11