#网页内容的回调函数 def contentWriteCallBack(self,buf): self.b.write(buf) #头部信息的回调函数 def headerWriteCallBack(self,buf): self.headerWrite.truncate()#从当前位置开始,后面的内容全部删除 self.headerWrite.write(str(buf)) #下载/上传进度 def progressWriteCallBack(self,downloadTotal,downloadNow,uploadTotal,uploadNow): if downloadTotal > 0: Progress = 'download progress: ' + str(round((downloadNow/downloadTotal)*100,2)) + '%' print Progress+" \r" else: if uploadTotal > 0: Progress = 'upload progress: ' + str(round((uploadNow/uploadTotal)*100,2)) + '%' print Progress+" \r" #######################回调函数结束################################################## if __name__=='__main__': from fileutil import FileUtil fileutil = FileUtil() downloadutil = DownloadUtil() value = downloadutil.download('http://s.taobao.com/search?q=10%E5%85%83%E5%8C%85%E9%82%AE') if value: print 'Login success' fileutil.writeIntoFile('C:/Users/guo_f/Desktop/compare/search_pycurl.html',value) else: print 'error'