python 爬取视频简单测试

2021/6/3 12:20:54

本文主要是介绍python 爬取视频简单测试,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

import requests


def download_file(url, path):
	with requests.get(url, stream=True) as r:
		chunk_size = 1024
		content_size = int(r.headers['content-length'])
		print(r,'ks')
  
		'下载开始'
		with open(path, "wb") as f:
			for chunk in r.iter_content(chunk_size=chunk_size):
				f.write(chunk)


if __name__ == '__main__':
    url='https://vd3.bdstatic.com//mda-meuj6t9f3z2j7bse//cae_h264_clips//1622296906542144945//mda-meuj6t9f3z2j7bse.mp4?auth_key=1622692948-0-0-3f8373256cde17047e56ac87175eb1bc&bcevod_channel=searchbox_feed&pd=1&pt=3&abtest='
    path = './a.mp4'
    download_file(url, path)

  



这篇关于python 爬取视频简单测试的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程