Is there a python library equivalent to php's curl_getinfo?

ε祈祈猫儿з 提交于 2020-07-08 14:53:15

问题


PHP's curl_getinfo returns detailed breakdown about request time (see the docs for more details). Is there a python library that can do the same thing?


回答1:


(py)curl has getinfo

import pycurl
import cStringIO

curl = pycurl.Curl()
buff = cStringIO.StringIO()
curl.setopt(pycurl.URL, 'http://example.org')
curl.setopt(pycurl.WRITEFUNCTION, buff.write)
curl.perform()

print "status code: %s" % curl.getinfo(pycurl.HTTP_CODE)


来源:https://stackoverflow.com/questions/28138038/is-there-a-python-library-equivalent-to-phps-curl-getinfo

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