开发者

problem sending an HTTPGET with PyCurl

I am having problems converting the following curl command into PyCurl:

curl -k --cert /tmp/blablabla "https://blablabla"

My attempt so far is shown below:

c 开发者_如何学C= pycurl.Curl()
c.setopt(pycurl.URL, submit_url)
c.setopt(pycurl.HTTPGET, 1)
b = StringIO.StringIO()
c.setopt(pycurl.WRITEFUNCTION, b.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.MAXREDIRS, 5)
c.setopt(pycurl.SSLCERT, cert)
c.setopt(pycurl.CAPATH,'/bla/bla/bla')
c.perform()
c.close()

This does not work. If anyone could tell me where I am going wrong that would be great!


Add "--libcurl example.c" to your curl command line to get to see better what libcurl options curl uses, then you can copy them into your pycurl program rather swiftly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜