def download(host, port, filepath):
conn = httplib.HTTPConnection(host, port)
conn.request("GET", "/"+filepath)
fp = open(filepath, 'wb')
resp =conn.getresponse()
#read 4096 bytes at a time
block_size = 4096
buffer = resp.read(block_size)
while(buffer):
fp.write(buffer)
buffer = resp.read(block_size)
fp.close()
conn.close()
#use: python download.py [host] [port] [filepath]
评论列表
文章目录