problem sending an HTTPGET with PyCurl

青春壹個敷衍的年華 提交于 2019-12-11 23:43:00

问题


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 = 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!


回答1:


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.



来源:https://stackoverflow.com/questions/5315070/problem-sending-an-httpget-with-pycurl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!