pycurl基本用法

直接上代码:示例很简单,抓一个报告页面,保存下来

import pycurl
oCurl=pycurl.Curl()
oCurl.setopt(pycurl.VERBOSE, 1)   #如果设置了,相当于要显示执行进度
oCurl.setopt(pycurl.FOLLOWLOCATION, 1)
oCurl.setopt(pycurl.MAXREDIRS, 1)
oCurl.setopt(pycurl.CONNECTTIMEOUT, 3)
oCurl.fp = file("report.%s.txt" % datetime.datetime.now().strftime("%Y%m%d%H%M%S"), "wt")
url = "http://172.27.198.62/ci_plat/views/build_report.php?pid=P%d-%s&bid=%d" % (nPlanId, strConfigId, nBuildId)
oCurl.setopt(pycurl.URL, url)
oCurl.setopt(oCurl.WRITEFUNCTION, oCurl.fp.write)
oCurl.perform()





你可能感兴趣的:(pycurl基本用法)