Skip to content

Instantly share code, notes, and snippets.

@nelsonjchen
Created October 16, 2013 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsonjchen/7002378 to your computer and use it in GitHub Desktop.
Save nelsonjchen/7002378 to your computer and use it in GitHub Desktop.
import pycurl
class Response(object):
""" utility class to collect the response """
def __init__(self):
self.chunks = []
def callback(self, chunk):
self.chunks.append(chunk)
def content(self):
return ''.join(self.chunks)
res = Response()
curl = pycurl.Curl()
curl.setopt(curl.URL, "https://config.nutricateonline.com/")
curl.setopt(curl.WRITEFUNCTION, res.callback)
curl.setopt(curl.CAINFO, "cacert.pem")
curl.setopt(curl.SSLCERT, "crt.pem")
curl.setopt(curl.SSLKEY, "key.pem")
curl.perform()
print res.content()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment