GithubHelp home page GithubHelp logo

bilibili_video_download's Introduction

Bilibili_video_download

Bilibili_video_download-B站视频下载

开发环境

Windows7 + python3 + requests

页面分析

通过分析b站视频播放请求可以得到以下几个关键api:

视频详情地址api https://api.bilibili.com/x/player/playurl?aid={}&cid={}&qn=0

获取cid详情api  https://api.bilibili.com/x/web-interface/view?aid={}

这样,思路很清晰了,首先通过av号获取到cid,再通过av号与cid来获取视频地址

测试

python bilibli_video_download.py

效果如下:

核心代码

def download_video( path, file_name, file_size):
    with open('{}.flv'.format(file_name), 'wb') as f:
        try:
            r = requests.get(path, stream=True)
            r.raise_for_status()
            print('视频大小为{}个字节,开始下载'.format(file_size))
            for i, chunk in enumerate(r.iter_content(1024)):
                f.write(chunk)
                process_bar( (i+1)*1024, file_size)
        except Exception as e:
            print('error : {}'.format(e))

bilibili_video_download's People

Contributors

gdmec07150735 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.