result = s.recv(8192)
num_bytes_recv += len(result)
index = result.find('\r\n\r\n')
result_wo_header = result[index+4:]
data = ""
with open(file_name, 'wb') as f:
data+=result_wo_header
while True:
print "number of byte recieve : ",num_bytes_recv
result = s.recv(8192)
print result
if not result:
break
num_bytes_recv+=len(result)
data+=result
f.write(data)
print "download complete"
s.close()
我试图从给定的URL下载任何类型的文件,代码完美地工作直到它到达结束或最后一块数据,它在那里停留长达10秒。我在这里做错了吗? up to 5~10 second from last "number of byte recieve : " to "download complete" 请帮助!!