dl_multithreading.py 文件源码

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

项目:163mooc_dumper 作者: wsdzl 项目源码 文件源码
def _len(url):
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML\
        , like Gecko) Chrome/50.0.2661.102 Safari/537.36',
        'Range': 'bytes=0-0',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
    }
    with requests.get(url, headers=headers) as r:
        length = r.headers['Content-Range']
        if length.find('0-0/') == -1:
            length = None
        else:
            length = length.split('0-0/')[-1]
            length = int(length) if length else 0
    if not length:
        del headers['Range']
        with requests.head(url, headers=headers) as r:
            length = r.headers['Content-Length']
            length = int(length) if length else 0
    return length
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号