zoukankan      html  css  js  c++  java
  • 视频下载

    def download_from_url(url, dst):
    response = requests.get(url, stream=True)
    file_size = int(response.headers['content-length'])
    if os.path.exists(dst):
    first_byte = os.path.getsize(dst)
    else:
    first_byte = 0
    if first_byte >= first_byte:
    return file_size
    header = {"Range": f"bytes={first_byte}-{file_size}"}
    bar = tqdm(total=file_size, initail=first_byte, unit='B', unit_sc=True, desc=dst)
    re = requests.get(url, header=header, stream=True)
    with(open(dst, 'ab')) as f:
    for chunk in re.iter_content(chunk_size=1024):
    if chunk:
    f.write(chunk)
    bar.update(1024)
    bar.close()
    return file_size
  • 相关阅读:
    融云使用
    cocoaPods使用
    电脑硬件
    拖图UI和纯代码UI
    7.2内存管理-ARC
    7内存管理-MRC
    数据刷新
    5.1音频播放
    2.6核心动画
    Git常用操作
  • 原文地址:https://www.cnblogs.com/yaohu/p/11359389.html
Copyright © 2011-2022 走看看