当前位置:   article > 正文

b站视频爬取(未封装)_b站视频爬取打包

b站视频爬取打包

b站视频爬取(未封装)

1、随便选取一个视频进行分析

  • 经过分析得出视频有两部分(一个音频一个视频)
    在这里插入图片描述

2、代码(将对应的MP3、MP4保存起来)

from urllib import request
# 为请求添加请求头
opener = request.build_opener()
opener.addheaders = [
    ('Referer','https://www.bilibili.com/bangumi/play/ep199612?from=search&seid=17094093942596385132'),
    ('User-Agent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.16 Safari/537.36')
]
request.install_opener(opener)

url_1 = 'https://upos-sz-mirrorhw.bilivideo.com/upgcxcode/85/81/34568185/34568185_da1-1-30032.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1589612693&gen=playurl&os=hwbv&oi=1874926467&trid=2d9c32f869154a9d825cab4234c3d7e1p&platform=pc&upsig=f7a1a0b3ec001c0e0c211e82b01813f7&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=314286954&logo=80000000'
url_2 = 'https://upos-sz-mirrorhw.bilivideo.com/upgcxcode/85/81/34568185/34568185_da1-1-30216.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1589612693&gen=playurl&os=hwbv&oi=1874926467&trid=2d9c32f869154a9d825cab4234c3d7e1p&platform=pc&upsig=cd1d603424ef110f565ec9f4809b98a0&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=314286954&logo=80000000'
request.urlretrieve(url=url_1,filename='1.mp4')
request.urlretrieve(url=url_2,filename='2.mp3')
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

3、将视频跟音频合并起来

import subprocess
subprocess.call('D:/xmind_about_python/复习/ffmpeg-20200515-b18fd2b-win64-static/bin/ffmpeg.exe -i 1.mp4 -i 2.mp3 -strict -2 -f mp4 4.mp4', shell=True)


  • 1
  • 2
  • 3
  • 4
'
运行
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/900035
推荐阅读
相关标签
  

闽ICP备14008679号