download.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:PythonP2PBotnet 作者: jhoward321 项目源码 文件源码
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]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号